如何取得工程当前工作目录?

billow007 2009-04-23 04:23:07
如题
...全文
85 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
deyter 2009-04-23
  • 打赏
  • 举报
回复
还有这么多的方法啊,收下先。
我就晓得Application.StartupPath和Environment.CurrentDirectory
chinese_zmm 2009-04-23
  • 打赏
  • 举报
回复
Environment.CurrentDirectory
wartim 2009-04-23
  • 打赏
  • 举报
回复
这个是当前目录,程序运行时就可以调用并保留下来也可以求当前的
wartim 2009-04-23
  • 打赏
  • 举报
回复

再给你一个c/s b/s 都能用的
        #region String GetCurrentFullPath() // 获取当前地址(通用,即可获得WinForm运行根目录也可获得Web IIS虚拟根目录
/// <summary>
/// 获取当前地址
/// </summary>
/// <returns>当前地址</returns>
public String GetCurrentFullPath()
{
String CurrentCodeBase = Assembly.GetExecutingAssembly().CodeBase;
CurrentCodeBase = CurrentCodeBase.Substring(8, CurrentCodeBase.Length - 8);
String[] Sections = CurrentCodeBase.Split(new char[] { '/' });
String Result = String.Empty;
for (int i = 0; i < Sections.Length - 1; i++)
Result += Sections[i] + "\\";
return Result;
}
#endregion
wartim 2009-04-23
  • 打赏
  • 举报
回复
System .AppDomain .CurrentDomain .BaseDirectory 
tailor_ms 2009-04-23
  • 打赏
  • 举报
回复
C/S

AppDomain.CurrentDomain.SetupInformation.ApplicationBase
jocklyhu 2009-04-23
  • 打赏
  • 举报
回复
C/S Application.StartupPath能获取到!
yingzhilian2008 2009-04-23
  • 打赏
  • 举报
回复
Environment.CurrentDiectory
Application.StartUpPath
可能有拼写错误
ericzhangbo1982111 2009-04-23
  • 打赏
  • 举报
回复
Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName);
清风六月 2009-04-23
  • 打赏
  • 举报
回复
Environment.CurrentDiectory
不过注意用openfileDialog时路径可能会被改变!
蓝海D鱼 2009-04-23
  • 打赏
  • 举报
回复
ASP.net

Server.MapPath("");

111,126

社区成员

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

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

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