C # How to get the project path

  Get console application root method

. 1 Environment.CurrentDirectory // get or set the current working directory of the fully qualified path 
2 AppDomain.CurrentDomain.BaseDirectory // Get directory group, which consists of an assembly for detecting a resolver assembly

  Made Web application root method

. 1 HttpRuntime.AppDomainAppPath.ToString (); // Get carried physical drive path of the application of the current application directory application domain. App_Data for obtaining 
2 the Server.MapPath ( "" ) or the Server.MapPath ( " ~ / " ); // returns the physical file path specified on the Web server virtual path opposite 
. 3 Request.ApplicationPath; // Get the server virtual application root directory of the ASP.NET application

  Get WinForm application with the method directory

. 1 Environment.CurrentDirectory.ToString (); // get or set the fully qualified path of the current working directory 
2 Application.StartupPath.ToString (); // get the path started the application executable file, the executable file does not include name 
. 3 Directory.GetCurrentDirectory (); // get the application of the current working directory 
. 4 AppDomain.CurrentDomain.BaseDirectory; // Get the base directory, which is solved by the assembly for detecting assembly procedure conflict 
. 5 AppDomain.CurrentDomain.SetupInformation.ApplicationBase ; // Gets or sets the name of the directory that contains the application

   Gets the name of the executable file

. Process.GetCurrentProcess () MainModule.FileName; // obtain the currently executing exe file name. 
Application.ExecutablePath; // get the path to start the application's executable file, including the name of the executable file

 Reference Site

  [1] https://www.cnblogs.com/rosesmall/p/8793844.html

Guess you like

Origin www.cnblogs.com/luyj00436/p/11653760.html