Six methods for obtaining the path from the Pocket PC

Source: Internet
Author: User

There are many methods to obtain a path in c #. The following are commonly used:
 
For example, the current executable path is: E:/temp/Pocket PC CopyFile/bin/Debug/Pocket PC CopyFile. EXE.
 
1. // obtain the current working directory of the application.
String path1 = System. IO. Directory. GetCurrentDirectory ();
MessageBox. Show ("Get the current working directory of the application:" + path1 );
// Return value: E: \ temp \ Pocket PC CopyFile \ bin \ Debug
 
2. // obtain the base Directory of the program.
String path2 = System. AppDomain. CurrentDomain. BaseDirectory;
MessageBox. Show ("Get the program's base Directory:" + path2 );
// Return value: E: \ temp \ Pocket PC CopyFile \ bin \ Debug \
 
3. // 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 );
// Return value: E: \ temp \ Pocket PC CopyFile \ bin \ Debug \
 
4. // obtain the path of the executable file that has 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 );
// Return value: E: \ temp \ Pocket PC CopyFile \ bin \ Debug
 
5. // obtain the executable file path and file name of 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 );
// Return value: E: \ temp \ Pocket PC CopyFile \ bin \ Debug \ Pocket PC CopyFile. EXE
 
6. // obtain or set the program URL
String path6 = System. Reflection. Assembly. GetExecutingAssembly (). GetName (). CodeBase;
MessageBox. Show ("Get or set the program URL:" + path6 );
// Return value: file: // E:/temp/Pocket PC CopyFile/bin/Debug/Pocket PC CopyFile. EXE
 
 
 
From # Define

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.