Question: I have a website in asp.net. I have hosted it on my server. My server has 3 directories named C,D,E. My Asp.net Application is in C drive. In a module I have uploaded Some Images which is stored in My Server's D directory. Now I want to Access it from asp.net Code but it display a error message as : 
"asp.net is a physical path but a virtual path was expected" . How Can I access my image from This Scenario. Please help me.... My Code is as follows..

```
ImageButton lnkbtn = sender as ImageButton;

       GridViewRow gvrow = lnkbtn.NamingContainer as GridViewRow;
       string fileName = grvImpact.DataKeys[gvrow.RowIndex].Values[3].ToString();
       string filePath = "D://Upload//CRDocument//" + fileName.ToString();

       if (fileName != null)
           {
           Response.ContentType = "image/jpg";
           Response.AddHeader("Content-Disposition", "attachment;filename=\"" + filePath + "\"");
           Response.TransmitFile(filePath);
           Response.End();
           }

```

It does not worked...

Answer: 
Use [Server.MapPath](http://msdn.microsoft.com/en-us/library/ms524632%28v=vs.90%29.aspx) for specifying the relative or virtual path to map to a physical directory.

```
string FilePath;
FilePath = Server.MapPath("/MyWebSite");

```
Lets say you have 

URL

```
www.mydomain.com/D/images/MyMegaImage.jpg

```

File System

```
c:\inetpub\mywebsite\wwwroot\D\images\MyMegaImage.jpg

```

in code you would have something like

```
string imageFileName = "MyMegaImage.jpg";
string FullFilePath = HttpContext.Current.Server.MapPath("/D/images/" + imageFileName);

```

then the variable FullFilePath should be computed in "c:\inetpub\mywebsite\wwwroot\D\images\MyMegaImage.jpg"