怎么利用C#返回 当前 应用程序的 路径?

afeny 2008-03-11 02:38:37
如题~ 比如我写了一个应用程序~ 然后用户运行了应用程序~ 这个时候我需要代码返回一个路径 这个路径就是当前应用程序 所在文件夹的路径~ 请问怎么写?
...全文
213 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
骑蚊子旅游 2008-03-12
  • 打赏
  • 举报
回复
Application.StartupPath 这个是肯定可以的。

你再好好看看你的代码是不是出了什么问题,或者贴出相关代码大家看一看
sun8134 2008-03-12
  • 打赏
  • 举报
回复
using System.Windows.Forms

string 路径=Application.StartupPath
xray2005 2008-03-12
  • 打赏
  • 举报
回复
'当前应用程序所在的目录路径
System.Environment.CurrentDirectory

'当前应用程序的绝对路径
System.Windows.forms.Application.ExecutablePath;


注意:LZ,你Debug的时候,这个路径是指到你项目做的文件夹的debug\bin这的
可以不要以为是在项目的文件夹.那肯定就不对了噻
ericzhangbo1982111 2008-03-12
  • 打赏
  • 举报
回复
string strAppPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName);
......
ericzhangbo1982111 2008-03-12
  • 打赏
  • 举报
回复
string strAppPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName);
......
anzhiqiang_touzi 2008-03-12
  • 打赏
  • 举报
回复
Application.StartupPath
b哈利路亚d 2008-03-12
  • 打赏
  • 举报
回复
Application.StartupPath
bing0804 2008-03-11
  • 打赏
  • 举报
回复

'当前应用程序所在的目录路径
System.Environment.CurrentDirectory

'当前应用程序的绝对路径
System.Windows.forms.Application.ExecutablePath;
yilanwuyu123 2008-03-11
  • 打赏
  • 举报
回复
应该是可行的呀
afeny 2008-03-11
  • 打赏
  • 举报
回复
用的是 c# 你们说的方法我都试过了 还是不行呀
meimen2 2008-03-11
  • 打赏
  • 举报
回复
.net2008相关技术,sliverlight,linq,db 开发群,群号:39698106
骑蚊子旅游 2008-03-11
  • 打赏
  • 举报
回复
楼主问的是WEB还是桌面软件?
上面的几位把答案都列出来了。

syjchyx 2008-03-11
  • 打赏
  • 举报
回复
webform:
Server.MapPath("~")

winform:
Application.StartupPath
panchenguang 2008-03-11
  • 打赏
  • 举报
回复
如果是asp.net环境,请使用Server.MapPath("./Model.htm")
boblaw 2008-03-11
  • 打赏
  • 举报
回复
Application.ExecutablePath //包括可執行文件的名稱
Application.StartupPath //不包括可執行文件的名稱
ycg_893 2008-03-11
  • 打赏
  • 举报
回复
using System.Windows.Forms; 命名空间

Application.ExecutablePath; 包括可执行文件名称

Application.StartupPath; 不包括打执行文件名称

niyoler 2008-03-11
  • 打赏
  • 举报
回复
Application.StartupPath???


C# winform 开发群,群号:57718204,我们期待您的加入!!
h_w_king 2008-03-11
  • 打赏
  • 举报
回复
System.Environment.CurrentDirectory

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧