C #.ProgramCurrent path7The most common method
String str1 = process. getcurrentprocess (). mainmodule. filename ;//Obtain the currently executedEXEFile Name.
String str2 = environment. currentdirectory ;//Obtain and set the full path of the current directory (that is, the directory from which the process starts.
//Remarks are as defined. if the process is started locally or in the root directory of the network drive, the value of this attribute is the drive name followed by a backslash (such as"C :\"). If the process is started in a subdirectory, the value of this attribute is a drive and subdirectory path without a backslash (such as"C: \ mysubdirectory").
String str3 = directory. getcurrentdirectory ();//Obtain the current working directory of the application.
String str4 = appdomain. currentdomain. basedirectory ;//Gets the base Directory, which is used by the Assembly conflict resolution program to detect the assembly.
String str5 = application. startuppath ;//Obtain the path of the executable file that started the application, excluding the name of the executable file.
String str6 = application. executablepath ;//Obtain the path of the executable file that started the application, including the name of the executable file.
String str7 = appdomain. currentdomain. setupinformation. applicationbase ;//Obtain or set the name of the directory containing the application.
1.System. Diagnostics. process. getcurrentprocess (). mainmodule. filename
Obtain the complete path of the module.
2.System. environment. currentdirectory
Get and set the current directory(Directory from which the process is started).
3.System. Io. Directory. getcurrentdirectory ()
Obtain the current working directory of the application. This is not necessarily the directory from which the program starts.C: \ wwwLi,This function may returnC: \ Documents ents and Settings \ zyb \,OrC: \ Program Files \ Adobe \,Sometimes I don't know what to return.
4.System. appdomain. currentdomain. basedirectory
Obtain the base Directory of the program.
5.System. appdomain. currentdomain. setupinformation. applicationbase
Obtain and set the name of the directory containing the application.
6.System. Windows. Forms. application. startuppath
Obtain the path of the executable file that started the application. Effect and2,5Same. Just5The returned string is followed by one more"\"Only
7.System. Windows. Forms. application. executablepath
Obtain the path, file name, effect, and1Same