Original link: http://blog.csdn.net/liudong8510/article/details/17264297 (written very practical, very detailed)
Gets the full path of the module. String path1 = System.Diagnostics.Process.GetCurrentProcess ().
Mainmodule.filename;
Gets and sets the fully qualified directory string path2 = System.Environment.CurrentDirectory for the current directory (the directory from which the process starts);
Gets the current working directory of the application string path3 = System.IO.Directory.GetCurrentDirectory ();
Gets the base directory of the program string path4 = System.AppDomain.CurrentDomain.BaseDirectory;
Gets and sets the name of the directory that contains the application string path5 = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
Gets the path to the executable file that started the application string path6 = System.Windows.Forms.Application.StartupPath;
Gets the path and filename of the executable file that started the application string path7 = System.Windows.Forms.Application.ExecutablePath;
StringBuilder str=new StringBuilder (); Str. Appendline ("System.Diagnostics.Process.GetCurrentProcess ()".
Mainmodule.filename: "+ path1); Str.
Appendline ("System.Environment.CurrentDirectory:" + path2); Str.
Appendline ("System.IO.Directory.GetCurrentDirectory ():" + path3); Str.
Appendline ("System.AppDomain.CurrentDomain.BaseDirectory:" + Path4); Str. Appendline ("SysteM.appdomain.currentdomain.setupinformation.applicationbase: "+ path5); Str.
Appendline ("System.Windows.Forms.Application.StartupPath:" + path6); Str.
Appendline ("System.Windows.Forms.Application.ExecutablePath:" + path7); string allpath = str.
ToString (); /* Output result * System.Diagnostics.Process.GetCurrentProcess ().
Mainmodule.filename:d:\work\prj\vp-vplatform\xmlandxsd\bin\release\xmlandxsd.vshost.exe
System.environment.currentdirectory:d:\work\prj\vp-vplatform\xmlandxsd\bin\release
System.IO.Directory.GetCurrentDirectory ():D: \work\prj\vp-vplatform\xmlandxsd\bin\release
System.appdomain.currentdomain.basedirectory:d:\work\prj\vp-vplatform\xmlandxsd\bin\release\ System.appdomain.currentdomain.setupinformation.applicationbase:d:\work\prj\vp-vplatform\xmlandxsd\bin\release \ system.windows.forms.application.startuppath:d:\work\prj\vp-vplatform\xmlandxsd\bin\release System.Windows.For Ms. Application.executablepath:d:\work\prj\vp-vplatform\xmlandxsd\bin\rElease\xmlandxsd.exe *