Home  |  Contact us    
Server.MapPath in Asp.Net


What is the purpose of Server.MapPath method in Asp.Net?

In Asp.Net Server.MapPath method maps the specified relative or virtual path to the corresponding physical path on the server. Server.MapPath takes a path as a parameter and returns the physical location on the hard drive.


Syntax
Suppose your Text files are located at D:\project\MyProject\Files\TextFiles

If the root project directory is MyProject and the aspx file is located at root then to get the same path use code

/* physical path of TextFiles */
string TextFilePath=Server.MapPath("Files/TextFiles");

Category: ASP.NET Faqs, Interview Questions & Answers



Ask New Questions
Microsoft.Net Framework
.Net 2.0 Namespaces
.Net Assemblies
OOPS Faqs in C#
ASP.Net Faqs
ASP.Net 2.0 Faqs
Web Services Faqs
ADO.Net Faqs
Database Faqs
OOPS Faqs
IT Project Management