// Obtain the complete path of the current process, including the file name (process name ).
String str = this. GetType (). Assembly. Location;
Result: X: \ xxx \ xxx.exe (.exefile directory. .exe file name)
// Obtain the complete path of the new Process component and associate it with the active Process, including the file name (Process name ).
String str = System. Diagnostics. Process. GetCurrentProcess (). MainModule. FileName;
Result: X: \ xxx \ xxx.exe (.exefile directory. .exe file name)
// Obtain and set the full path of the current directory (that is, the directory from which the process starts.
String str = System. Environment. CurrentDirectory;
Result: X: \ xxx (directory of the .exe file)
// Obtain the base Directory of the current application domain of the current Thread, which is used by the Assembly conflict resolution program to detect the assembly.
String str = System. AppDomain. CurrentDomain. BaseDirectory;
Result: X: \ xxx \ (directory where the .exe file is located + "\")
// Obtain and set the name of the directory containing the application. (Recommended)
String str = System. AppDomain. CurrentDomain. SetupInformation. ApplicationBase;
Result: X: \ xxx \ (directory where the .exe file is located + "\")
// Obtain the path of the executable file that started the application, excluding the name of the executable file.
String str = System. Windows. Forms. Application. StartupPath;
Result: X: \ xxx (directory of the .exe file)
// Obtain the path of the executable file that started the application, including the name of the executable file.
String str = System. Windows. Forms. Application. ExecutablePath;
Result: X: \ xxx \ xxx.exe (.exefile directory. .exe file name)
// Obtain the current working directory of the application (unreliable ).
String str = System. IO. Directory. GetCurrentDirectory ();
Result: X: \ xxx (directory of the .exe file)
From _ ya