WinForm Gets a collection of methods for the current path of the application, as follows, which is worth collecting//gets the full path of the current process, including the file name (process name). stringstr = This. GetType (). Assembly.location;result:x:\xxx\xxx\xxx.exe (the directory where the. exe file resides+. EXE file name)//gets the full path of the new process component and its main module associated with the currently active process, including the file name (process name). stringstr =System.Diagnostics.Process.GetCurrentProcess (). Mainmodule.filename;result:x:\xxx\xxx\xxx.exe (the directory where the. exe file resides+. EXE file name)//gets and sets the fully qualified path to the current directory (that is, the directory from which the process starts). stringstr =system.environment.currentdirectory;result:x:\xxx\xxx (the directory where the. exe file resides)//gets the base directory of the current application domain for Thread, which is used by the Assembly resolver to probe assemblies. stringstr =system.appdomain.currentdomain.basedirectory;result:x:\xxx\xxx\ (the directory where the. exe file resides+"\")//gets and sets the name of the directory that contains the application. stringstr =system.appdomain.currentdomain.setupinformation.applicationbase;result:x:\xxx\xxx\ (the directory where the. exe file resides+"\")//gets the path to the executable file that launched the application, not including the name of the executable file. stringstr =system.windows.forms.application.startuppath;result:x:\xxx\xxx (the directory where the. exe file resides)//gets the path to the executable file that launched the application, including the name of the executable file. stringstr =System.windows.forms.application.executablepath;result:x:\xxx\xxx\xxx.exe (the directory where the. exe file resides+. EXE file name)//gets the current working directory of the application (unreliable). stringstr =System.IO.Directory.GetCurrentDirectory (); result:x:\xxx\xxx (the directory where the. exe file resides)
C # Get the current program run directory Daquan