System.Environment.CurrentDirectory 获取和设置当前目录(该进程从中启动的目录)的完全限定目录。
System.IO.Directory.GetCurrentDirectory() 获取应用程序的当前工作目录。
System.Windows.Forms.Application.StartupPath 获取启动了应用程序的可执行文件的路径
------------------------------------------------------
System.AppDomain.CurrentDomain.BaseDirectory 获取程序的基目录。
System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase 获取和设置包括该应用程序的目录的名称。
AppDomain.CurrentDomain.BaseDirectory 获取当前应用程序所在目录的路径,最后包含“\”
System.Threading.Thread.GetDomain().BaseDirectory 获取当前应用程序所在目录的路径,最后包含“\”
------------------------------------------------------
System.Windows.Forms.Application.ExecutablePath 获取启动了应用程序的可执行文件的路径及文件名
System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName 获取模块的完整路径,包括文件名。
------------------------------------------------------
在卸载程序获取系统安装的目录
System.Reflection.Assembly curPath = System.Reflection.Assembly.GetExecutingAssembly();
string path=curPath.Location;
//得到安装程序类SetupLibrary文件的路径,获取这个文件路径所在的目录即得到安装程序的目录
------------------------------------------------------