There are many methods to obtain the path in C #, which are generally used in the following five ways:
// Obtain the applicationProgram.
String path1 = system. Io. Directory. getcurrentdirectory ();
MessageBox. Show ("Get the current working directory of the application:" + path1 );
// Obtain the base Directory of the program.
String path2 = system. appdomain. currentdomain. basedirectory;
MessageBox. Show ("Get the program's base Directory:" + path2 );
// Obtain and set the Directory Name of the application.
String path3 = system. appdomain. currentdomain. setupinformation. applicationbase;
MessageBox. Show ("Get and set the name of the directory containing the application:" + path3 );
// Obtain the path of the executable file that started the application, excluding the name of the executable file.
String path4 = system. Windows. Forms. application. startuppath;
MessageBox. Show ("Get the path of the executable file that started the application, excluding the executable file name:" + path4 );
// Obtain the path and file name of the executable file that has started the application
String path5 = system. Windows. Forms. application. executablepath;
MessageBox. Show ("Get the path and file name of the executable file that started the application:" + path5 );
ArticleSource: http://www.cnblogs.com/purplefox2008/archive/2009/06/04/1495873.html