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 (. exe file in the same directory as +.exe filename)
//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 (. exe file in the same directory as +.exe filename)
//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 is located +"\")
//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 is located +"\")
//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 (. exe file in the same directory as +.exe filename)
//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)