怎么在代码里应用文件的相对路径啊? 当前目录 Bitmap(@"abc.bmp");../ 表示回退比如从 a文件夹页面abc.aspx到b文件页面efg.aspx要这样Response.Redirect(@"..\b\efg.aspx"); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 string bmp=GetApplicationPath()+"\\abc.bmp"; public static string GetApplicationPath() { return Application.StartupPath; } 用System.AppDomain.CurrentDomain.BaseDirectory可以得到当前程序的根目录你也可以直接使用".\customer.mdb","..\customer.mdb"还可以使用 Application.StartUpPath来获得当前应用的所在路径 str=Path.GetExtension(Application.ExecutablePath)+"\n"; str=str+Path.GetFileNameWithoutExtension(Application.ExecutablePath)+"\n"; str=str+Path.GetPathRoot(Application.ExecutablePath)+"\n"; str=str+Application.ExecutablePath+"\n"; str=str+Path.GetDirectoryName(Application.ExecutablePath)+"\n";反射:System.Reflection.Assembly.GetExecutingAssembly().Location Application.StartupPath 在WINFORM中Server.MapPath 在WEBFORM中 liduke(天下有雪) is right! 在C#里面获得应用程序的当前路径Environment.CurrentDirectory获取应用程序的当前工作目录。System.IO.Directory.GetCurrentDirectory()AppDomain.CurrentDomain.BaseDirectoryApplication.StartupPathApplication.ExecutablePath--获取和设置当前目录(即该进程从中启动的目录)的完全限定路径。 谁能讲下IList<T> FoxPro中Memo字段 .chm阅读器问题 怎样来得到数值? C#复制文件时出现的怪问题 高分 请教发送GET包到网页的的办法! C# textbox 如何转换 成 数值格式? C# 做 音视频聊天室 在GUI界面上撤销一步对数据库的操作的编辑 有哪些思路方案 由于具体程序运行时间较长 想要显示个窗口给用户 让用户不要以为是程序死机或停止了 如何把窗体设为模式打开方式? 请推荐一本用C#开发asp.net的好书?
public static string GetApplicationPath()
{
return Application.StartupPath;
}
可以得到当前程序的根目录你也可以直接使用".\customer.mdb","..\customer.mdb"
还可以使用 Application.StartUpPath来获得当前应用的所在路径 str=Path.GetExtension(Application.ExecutablePath)+"\n";
str=str+Path.GetFileNameWithoutExtension(Application.ExecutablePath)+"\n";
str=str+Path.GetPathRoot(Application.ExecutablePath)+"\n";
str=str+Application.ExecutablePath+"\n";
str=str+Path.GetDirectoryName(Application.ExecutablePath)+"\n";
反射:
System.Reflection.Assembly.GetExecutingAssembly().Location
Server.MapPath 在WEBFORM中
获取应用程序的当前工作目录。
System.IO.Directory.GetCurrentDirectory()
AppDomain.CurrentDomain.BaseDirectory
Application.StartupPath
Application.ExecutablePath
--获取和设置当前目录(即该进程从中启动的目录)的完全限定路径。