The directory path where C # gets the program

Source: Internet
Author: User
Method 1:
Directory.GetCurrentDirectory ().
This method can only be used in. NET, the feature is not supported in NetCF, and an exception is thrown when it is called.  Gets the current directory, which is not necessarily the true path, and is associated with the OpenFile dialog box.  It is not recommended. Method 2:system.windows.forms.application.startuppath This method can only be used in. NET, the feature is not supported in NetCF, and an exception is thrown when it is called. Gets the path to run the program. Recommended Use

Method 3:
System.IO.Path.GetDirectoryName (assembly.getexecutingassembly (). GetName (). CodeBase).
This method is given in MSDN for the NETCF platform, when tested in the path obtained in the net full version of the PC, it is found that the final path with the file: prefix, such as file:\c:\debug, generally we do not need this prefix, can be manually removed.

Method 4:
System.IO.Path.GetDirectoryName (assembly.getexecutingassembly (). Manifestmodule.fullyqualifiedname).
This method is also for the solution given by NETCF, when consistent results can be obtained in the net full version of the PC test. Recommended Use

The directory path where C # gets the program

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.