C # How to obtain the application program running path

Source: Internet
Author: User

For. net. There are several ways to get the applicationProgramPath.

1. server. mappath
2. system. Windows. Forms. startuppath
3. type. Assembly. Location

Method 2 can be applied to console applications, winform applications, Windows Services, method 1 can be applied to Web applications, and method 3 can be applied.
But method 3 is the path to load the application. For a web application, the obtained path is the c: \ windows \ Microsoft. NET \ framework \ v1.1.4322 \ temporary ASP. NET Files directory. Therefore, we recommend that you use server. mappath for web projects. Otherwise, method 2 is recommended. If you create a new class library. You can add a reference to system. Windows. Forms. startuppath for use.

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.