C#中如何获取应用程序运行所在的目录 收藏
方法如下: 1、Application.ExecutablePath 获取启动了应用程序的可执行文件的路径,包括可执行文件的名称。
2、Application.StartupPath 获取启动了应用程序的可执行文件的路径,不包括可执行文件的名称。
3、Directory.GetCurrentDirectory 获取应用程序的当前工作目录。 需要引用 System.IO Directory.SetCurrentDirectory() 将应用程序的当前工作目录设置为指定的目录。
4、Environment.CurrentDirectory 获取或设置当前工作目录的完全限定路径。
5、AppDomainSetup.ApplicationBase 获取或设置包含该应用程序的目录的名称。 AppDomain.CurrentDomain.SetupInformation.ApplicationBase (作用相同)
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/kinber/archive/2008/12/16/3532803.aspx |
|
来自: COPY&PASTE > 《C#》