C # Get the current program run directory Daquan

Source: Internet
Author: User

WinForm Gets a collection of methods for the current path of the application, as follows, which is worth collecting//gets the full path of the current process, including the file name (process name). stringstr = This. GetType (). Assembly.location;result:x:\xxx\xxx\xxx.exe (the directory where the. exe file resides+. EXE file name)//gets the full path of the new process component and its main module associated with the currently active process, including the file name (process name). stringstr =System.Diagnostics.Process.GetCurrentProcess (). Mainmodule.filename;result:x:\xxx\xxx\xxx.exe (the directory where the. exe file resides+. EXE file name)//gets and sets the fully qualified path to the current directory (that is, the directory from which the process starts). stringstr =system.environment.currentdirectory;result:x:\xxx\xxx (the directory where the. exe file resides)//gets the base directory of the current application domain for Thread, which is used by the Assembly resolver to probe assemblies. stringstr =system.appdomain.currentdomain.basedirectory;result:x:\xxx\xxx\ (the directory where the. exe file resides+"\")//gets and sets the name of the directory that contains the application. stringstr =system.appdomain.currentdomain.setupinformation.applicationbase;result:x:\xxx\xxx\ (the directory where the. exe file resides+"\")//gets the path to the executable file that launched the application, not including the name of the executable file. stringstr =system.windows.forms.application.startuppath;result:x:\xxx\xxx (the directory where the. exe file resides)//gets the path to the executable file that launched the application, including the name of the executable file. stringstr =System.windows.forms.application.executablepath;result:x:\xxx\xxx\xxx.exe (the directory where the. exe file resides+. EXE file name)//gets the current working directory of the application (unreliable). stringstr =System.IO.Directory.GetCurrentDirectory (); result:x:\xxx\xxx (the directory where the. exe file resides)

C # Get the current program run directory Daquan

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.