1. root directory
. // Or directly give the file name, which is the path to the root directory.
For example, Path = "test. xml" and Path = ". // test. xml" mean one thing.
2. The parent directory of the root directory is specified in the bin folder in C #.
.. // The upper two levels of the root directory of the application
3. Specify the Level 3 directory above the root directory, that is, in the same directory as bin in C #.
.. // Test. xml indicates the Gs. MDB file in the third-level directory of the root directory.
If you want to specify a file in the specified folder in this directory, it should be as follows :.. //.. // XML // test. XML indicates test. XML file.
4. Specify the level 4 directory to the root directory, as shown below:
.. // ../So that the level 4 directory of the root directory is specified.
.. // ../.. // XML // test. xml. This specifies the path Gs. MDB in the Dir folder in this directory.
5. relative path of a file
.. // Draw // XML // test. xml. For example, there are several folders named XML
, Draw, tool, and the application is now in the XML folder, this path means to specify test. XML file path.
Original article: http://blog.sina.com.cn/s/blog_449f737a0100hj07.html
1. Get and set the fully qualified path of the current directory.
String STR = system. environment. currentdirectory;
Result: C:/XXX/xxx
2. Obtain the path of the executable file that started the application, excluding the name of the executable file.
String STR = system. Windows. Forms. application. startuppath;
Result: C:/XXX/xxx
3. Obtain the complete path of the new process component and associate it with the active process, including the file name.
String STR = system. Diagnostics. process. getcurrentprocess (). mainmodule. filename;
Result: C:/XXX/xxx.exe
4. Obtain the base Directory of the current application domain of the current thread, which is used by the Assembly conflict resolution program to detect the assembly.
String STR = system. appdomain. currentdomain. basedirectory;
Result: C:/XXX/
5. Obtain the current working directory of the application.
String STR = system. Io. Directory. getcurrentdirectory ();
Result: C:/XXX/xxx
6. Get and set the name of the directory containing the application.
String STR = system. appdomain. currentdomain. setupinformation. applicationbase;
Result: C:/XXX/
7. Obtain the complete path of the current process, including the file name.
String STR = This. GetType (). Assembly. location;
Result: C:/XXX/xxx.exe
8. Obtain the path of the executable file that started the application, including the name of the executable file.
String STR = system. Windows. Forms. application. executablepath;
Result: C:/XXX/xxx.exe
In addition, it is more common to configure a specific path through the XML file to achieve a reasonable planning of the specific storage location of the configuration file, such as the path in the configuration file on the web.
String str1 = process. getcurrentprocess (). mainmodule. filename; // obtain the file name of the currently executed exe.
String str2 = environment. currentdirectory; // gets and sets the fully qualified path of the current directory (that is, the directory from which the process starts.
// The remarks are as defined. if the process is started in the local or root directory of the network drive, the value of this attribute is the drive name followed by a backslash (such as "C: /"). If the process is started in a subdirectory, the value of this attribute is a drive and subdirectory path (such as "C:/mysubdirectory") without a backslash ").
String str3 = directory. getcurrentdirectory (); // obtain the current working directory of the application.
String str4 = appdomain. currentdomain. basedirectory; // gets the base Directory, which is used by the Assembly conflict resolution program to detect the assembly.
String str5 = application. startuppath; // obtain the path of the executable file that started the application, excluding the name of the executable file.
String str6 = application. executablepath; // obtain the path of the executable file that started the application, including the name of the executable file.
String str7 = appdomain. currentdomain. setupinformation. applicationbase; // obtain or set the name of the directory containing the application.