【转】C#(ASP.Net)获取当前路径的方法集合
转自:http://www.gaobo.info/read.php/660.htm
- //获取当前进程的完整路径,包含文件名(进程名)。
- string str = this.GetType().Assembly.Location;
- result: X:/xxx/xxx/xxx.exe (.exe文件所在的目录+.exe文件名)
- //获取新的 Process 组件并将其与当前活动的进程关联的主模块的完整路径,包含文件名(进程名)。
- string str = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
- result: X:/xxx/xxx/xxx.exe (.exe文件所在的目录+.exe文件名)
- //获取和设置当前目录(即该进程从中启动的目录)的完全限定路径。
- string str = System.Environment.CurrentDirectory;
- result: X:/xxx/xxx (.exe文件所在的目录)
- //获取当前 Thread 的当前应用程序域的基目录,它由程序集冲突解决程序用来探测程序集。
- string str = System.AppDomain.CurrentDomain.BaseDirectory;
- result: X:/xxx/xxx/ (.exe文件所在的目录+"/")
- //获取和设置包含该应用程序的目录的名称。
- string str = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
- result: X:/xxx/xxx/ (.exe文件所在的目录+"/")
- //获取启动了应用程序的可执行文件的路径,不包括可执行文件的名称。
- string str = System.Windows.Forms.Application.StartupPath;
- result: X:/xxx/xxx (.exe文件所在的目录)
- //获取启动了应用程序的可执行文件的路径,包括可执行文件的名称。
- string str = System.Windows.Forms.Application.ExecutablePath;
- result: X:/xxx/xxx/xxx.exe (.exe文件所在的目录+.exe文件名)
- //获取应用程序的当前工作目录(不可靠)。
- string str = System.IO.Directory.GetCurrentDirectory();
- result: X:/xxx/xxx (.exe文件所在的目录)
.NET中三种获取当前路径的代码
- //Web编程
- HttpContext.Current.Server.MapPath("FileName")
- System.Web.HttpContext.Current.Request.Path
- //Windows编程
- System.Environment.CurrentDirectory
- //Mobile编程
- Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
【转】C#(ASP.Net)获取当前路径的方法集合的更多相关文章
- ASP.NET获取根目录的方法集合
编写程序的时候,经常需要用的项目根目录,自己总结如下: 1.取得控制台应用程序的根目录方法 方法1.Environment.CurrentDirectory 取得或设置当前工作目录的完整限定路径 方法 ...
- C#获取当前路径的方法
C#获取当前路径的方法如下: 1. System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName -获取模块的完整路径. 2. ...
- ASP.NET获取路径的方法
原文:[转载]ASP.NET获取路径的方法 HttpContext.Current.Request.PhysicalPath; // 获得当前页面的完整物理路径.比如 F:\XFU.NSQS\p ...
- Winform获取应用程序的当前路径的方法集合(转)
Winform获取应用程序的当前路径的方法集合,具体如下,值得收藏 //获取当前进程的完整路径,包含文件名(进程名). string str = this.GetType().Assembly.Loc ...
- Java 获取当前路径的方法总结
Java 获取当前路径的方法总结 1.利用System.getProperty()函数获取当前路径: System.out.println(System.getProperty("user. ...
- C#获取当前路径的方法如下
1. System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName -获取模块的完整路径. 2. System.Environm ...
- java获取当前路径的方法
1.System.getProperty("user.dir") 函数获取当前路径 // 获取当前路径方式1 System.out.println(System.getProper ...
- 【转载】ASP.NET获取路径的方法
HttpContext.Current.Request.PhysicalPath; // 获得当前页面的完整物理路径.比如 F:\XFU.NSQS\project\website\Default ...
- Python 获取当前路径的方法
Python2.7 中获取路径的各种方法 sys.path 模块搜索路径的字符串列表.由环境变量PYTHONPATH初始化得到. sys.path[0]是调用Python解释器的当前脚本所在的目录. ...
随机推荐
- css写带边框的三角形
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- [转] FastMM使用详解
FastMM使用详解 一.引言 FastMM 是适用于delphi的第三方内存管理器,在国外已经是大名鼎鼎,在国内也有许多人在使用或者希望使用,就连 Borland 也在delphi2007 ...
- 01背包 ZOJ 3931 Exact Compression
题目连接 题意:n个数字构建哈夫曼树,问是否存在这样一棵树使得:(Fi数字大小,Ci哈夫曼表示下,'0'的数量) 分析:每次从优先队列取出两个数字可以互换位置,这样可以01互换.设a[i] <= ...
- web工程spring+ibatis单元测试
web工程spring+ibatis在本地做单元测试,用例如下: package wanghongye; import org.junit.Before; import org.junit.Test; ...
- Shell 编程基础之 If 练习
一.语法 if [ condition ]; then # 当 condition 成立时,执行内容: fi # 将 if 反过来写,fi 结束 if 之意 if [ condition ]; the ...
- sql over的作用及用法
over不能单独使用,要和分析函数:rank(),dense_rank(),row_number()等一起使用.其参数:over(partition by columnname1 order by c ...
- Visual Studio: whether auto-building when press the debug button
Tools -> Options -> Projects and Solutions->Build and Run -> choose an option for On Run ...
- 目前quanben评十大哲学家
排名分先后,包含时间.地区和主要正面成就以及其他代表人物. 1. 伊曼努尔·康德:十八世纪:东普鲁士:理性的界限,现象和本体分立以及主体的地位2. 柏拉图:公元前三四百年:古希腊:理想(念)世界3. ...
- AVD模拟器运行异常
The connection to adb is down, and a severe error has occured. (1)现将eclipse关闭 (2)打开命令行(cmd),输入:cd + ...
- highcharts 时间少8小时问题
Highcharts 中默认开启了UTC(世界标准时间),由于中国所在时区为+8,所以经过 Highcharts 的处理后会减去8个小时. 如果不想使用 UTC,有2种方法可供使用: 1.在使用Hig ...