当前位置: 移动技术网 > IT编程>开发语言>c# > C# 获取目录路径

C# 获取目录路径

2019年09月15日  | 移动技术网IT编程  | 我要评论
console.writeline(system.windows.forms.application.startuppath);//获取启动了应用程序的可执行文件的路径,不包括可执行文件的名称。(windows from应用程序才有效)
//输出结果:c:\getpathinfo\getpath\bin\debug

console.writeline(system.environment.currentdirectory);//获取或设置当前工作目录的完全限定路径。
//输出结果:c:\getpathinfo\getpath\bin\debug

console.writeline(system.io.directory.getcurrentdirectory());//获取应用程序的当前工作目录。
//输出结果:c:\getpathinfo\getpath\bin\debug

console.writeline(system.appdomain.currentdomain.basedirectory);//获取基目录,它由程序集冲突解决程序用来探测程序集。
//输出结果:c:\getpathinfo\getpath\bin\debug\

console.writeline(system.appdomain.currentdomain.setupinformation.applicationbase);//获取或设置包含该应用程序的目录的名称。
//输出结果:c:\getpathinfo\getpath\bin\debug\

console.writeline(system.windows.forms.application.executablepath);//获取启动了应用程序的可执行文件的路径,包括可执行文件的名称。(windows from应用程序才有效)
//输出结果:c:\getpathinfo\getpath\bin\debug\getpath.exe

console.writeline(system.diagnostics.process.getcurrentprocess().mainmodule.filename);//获取模块的完整路径。
//输出结果:c:\getpathinfo\getpath\bin\debug\getpath.vshost.exe

此处项目路径是:c:\getpathinfo\

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网