Go, original address: http://blog.csdn.net/yanlele424/article/details/7329389
1. Gets and sets the fully qualified path to the current directory.
string str = System.Environment.CurrentDirectory;
result:c:xxxxxx
2. Gets the path to the executable file that launched the application, not including the name of the executable file.
string str = System.Windows.Forms.Application.StartupPath;
Result:c:xxxxxx
3. Gets the full path of the new process component and associates it with the main module associated with the currently active process, including the file name.
String str = System.Diagnostics.Process.GetCurrentProcess (). Mainmodule.filename;
Result:c:xxxxxxxxx.exe
4. Gets the base directory of the current application domain for Thread, which is used by the Assembly resolver to probe assemblies.
string str = System.AppDomain.CurrentDomain.BaseDirectory;
Result:c:xxxxxx
5. Get the current working directory of the application.
String str = System.IO.Directory.GetCurrentDirectory ();
Result:c:xxxxxx
6. Gets and sets the name of the directory that contains the application.
string str = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
Result:c:xxxxxx
7. Gets the full path of the current process, including the file name.
String str = this. GetType (). Assembly.location;
Result:c:xxxxxxxxx.exe
8. Get the path to the executable file that launched the application, including the name of the executable file.
string str = System.Windows.Forms.Application.ExecutablePath;
Result:c:xxxxxxxxx.exe
---------------------------------------------------------------------------------
In a DLL, it is sometimes necessary to use the resources in the main invoker, which will correctly obtain information such as the name of the calling program and its path. This needs to be distinguished from the name and path of the calling DLL itself!
This involves the use of the System.Reflection.Assembly assembly class.
getexecutingassembly : Gets the assembly that contains the code that is currently executing
getcallingassembly : Returns the System.Reflection.Assembly of the method that invokes the currently executing method
C # WinForm methods to get the current path of executing programs