I have obtained the project path through the experiment in the following ways:
Obtain the complete absolute path of the project.
String Path = system. appdomain. currentdomain. basedirectory. tostring ();
String Path = server. mappath (".");// This "." can be changed to another folder name in the project file.
Output Asp.net website path
Private Void Responsehtml ()
{
System. Text. stringbuilder sb = New System. Text. stringbuilder ();
SB. append ( String . Format ( " Current Time: {0} " , Server. htmlencode (datetime. Now. tostring ())));
SB. append ( " <Br/> " );
SB. append ( String . Format ( " The Virtual Path of the current request: {0} " , Server. htmlencode (request. currentexecutionfilepath )));
SB. append ( " <Br/> " );
SB. append ( String . Format ( " Get current applicationProgramRoot directory path of: {0} " , Server. htmlencode (request. applicationpath )));
SB. append ( " <Br/> " );
SB. append ( String . Format ( " The Virtual Path of the current request: {0} " , Server. htmlencode (request. filepath )));
SB. append ( " <Br/> " );
SB. append ( String . Format ( " The Virtual Path of the current request: {0} " , Server. htmlencode (request. Path )));
SB. append ( " <Br/> " );
SB. append ( String . Format ( " Obtain the physical file system path of the root directory of the currently running application: {0} " , Server. htmlencode (request. physicalapplicationpath )));
SB. append ( " <Br/> " );
SB. append ( String . Format ( " Obtain the physical file system path corresponding to the requested URL: {0} " , Server. htmlencode (request. physicalapplicationpath )));
SB. append ( " <Br/> " );
Response. Write (sb. tostring ());
}
}
Output: Current Time: 10:26:47
The Virtual Path of the current request:/test/gauge. aspx
Obtain the root directory path of the current application:/test
The Virtual Path of the current request:/test/gauge. aspx
The Virtual Path of the current request:/test/gauge. aspx
Obtain the physical file system path of the root directory of the currently running application: D: \ Asp.net test project \ test \
Obtain the path of the physical file system corresponding to the requested URL: D: \ Asp.net test project \ test \
If you have other methods, thank you for providing them and sharing them.
Everyone learns and communicates with each other