1.Asp.Net WebForm uses
"Request.PhysicalApplicationPath" to get the physical path of the virtual directory where the site is located, and finally contains "";
2.C# WinForm uses
A: "Application.StartupPath": Gets the directory where the current application is located Path, does not contain "" at the end;
B: "Application.ExecutablePath": Gets the path of the current application file, including the name of the file;
C: "AppDomain.CurrentDomain.BaseDirectory": Gets the path of the directory where the current application is located, Contains "" at the end;
D: "System.Threading.Thread.GetDomain().BaseDirectory": Gets the path to the directory where the current application is located, and contains "" at the end;
E: "Environment.CurrentDirectory": Gets the path of the current application's directory Path, does not contain "" at the end;
F: "System.IO.Directory.GetCurrentDirectory": Gets the path of the current application, does not contain "" at the end;
3.C# Windows Service
Use "AppDomain.CurrentDomain.BaseDirectory" Or "System.Threading.Thread.GetDomain().BaseDirectory";
Using "Environment.CurrentDirectory" and "System.IO.Directory.GetCurrentDirectory" will get the path of the "system32" directory;
If you want to use "Application.StartupPath" Or "Application.ExecutablePath", you need to manually add a reference to "System.Windows.Forms.dll" and declare the reference with "using System.Windows.Forms" at the beginning of the program;
4. Get the system installation in the uninstaller Directory
System.Reflection.Assembly curPath = System.Reflection.Assembly.GetExecutingAssembly();
string path=curPath.Location;//Get the path to the installation program class SetupLibrary file. Get the directory where this file path is located to get the installation program Directory
http://blog.163.com/dykj_dxj/blog/static/254925252010830113424205/