Windows Form和Web Form通用的当前应用程序所在路径获取方法
Windows Form和Web Form通用的当前应用程序所在路径获取方法
System.AppDomain.CurrentDomain.BaseDirectory
或者
System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase
下面是几个获取当前应用程序所在路径方法的执行结果:
Web Form
System.Environment.CurrentDirectory:
C:Program FilesMicrosoft Visual Studio 9.0Common7IDE
System.AppDomain.CurrentDomain.BaseDirectory:
F:PraticeAppCurrentRunPathWebFormPath
System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase:
F:PraticeAppCurrentRunPathWebFormPath
System.IO.Directory.GetCurrentDirectory():
C:Program FilesMicrosoft Visual Studio 9.0Common7IDE
Windows Form
System.Environment.CurrentDirectory:
F:PraticeAppCurrentRunPathWindowsFormsPathinDebug
System.AppDomain.CurrentDomain.BaseDirectory:
F:PraticeAppCurrentRunPathWindowsFormsPathinDebug
System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase:
F:PraticeAppCurrentRunPathWindowsFormsPathinDebug
System.Windows.Forms.Application.StartupPath:
F:PraticeAppCurrentRunPathWindowsFormsPathinDebug
System.IO.Directory.GetCurrentDirectory():
F:PraticeAppCurrentRunPathWindowsFormsPathinDebug
参考文档:
C#获取当前程序运行路径的方法集合
http://www.cnblogs.com/cocoulong/archive/2010/01/30/1660119.html
c#获取当前应用程序所在路径
http://www.cnblogs.com/baaigeini/archive/2009/03/09/1407078.html
补充:软件开发 , C# ,