Application.StartupPath——獲取啓動了應用程序的可執行文件的路徑,不包括可執行文件的名稱。
Environment.CurrentDirectory——獲取和設置當前目錄(即該進程從中啓動的目錄)的完全限定路徑。
Application.ExecutablePath——獲取啓動了應用程序的可執行文件的路徑,包括可執行文件的名稱。
通過調用Process.GetCurrentProcess().MainModule.FileName可獲得當前執行的exe的文件名。
AppDomain.CurrentDomain.SetupInformation.ApplicationBase獲取當前應用程序所在的路徑。
1、Application.ExecutablePath
2、Application.StartupPath
3、Application.UserAppDataRegistry.ToString()
4、System.Environment.CurrentDirectory.ToString()
5、Directory.GetCurrentDirectory()
6、AppDomain.CurrentDomain.BaseDirectory
string GetAppPath()
{
string FileName=System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase;
FileName=FileName.Substring ( 0,FileName.LastIndexOf("//"));
return FileName;
}