HttpRequest::MapPath Method (String)
Maps the specified virtual path to a physical path.
Assembly: System.Web (in System.Web.dll)
The MapPath property potentially contains sensitive information about the hosting environment. The return value should not be displayed to users.
The following code example uses the MapPath method to convert a virtual path to a fully qualified physical path on the server. This example has two parts:
An .aspx page maps the path, reads the file, and displays results of the read operation.
A class, UpperCaseFilterStream, that changes all characters passed through it to uppercase.
The first part of the example shows how to convert a virtual path to a fully qualified physical path using the MapPath method. This physical path is then passed to a StreamReader object, which obtains the contents of the file. The Write method is then called to display the content of the file on the page. The Filter property is used to attach a filter to the response stream that makes the text displayed to the page all uppercase.
The second part of the example shows a class that inherits from Stream and converts all characters in a stream to uppercase. Put this code in the App_Code folder for your application.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.