Search code examples
asp.netserver.mappath

server.mappath returning wrong path


Sever.mappath is returning wrong path that is I think it is converting the initial part of the path to lowercase which is the problem;

 String path = Server.MapPath("~/UploadImages/");

When I check for the path in my page by storing it in a textbox it returns:

c:\users\dell\documents\visual studio 2013\Projects\OFR\OFR\UploadImages\

instead of

C:\Users\DELL\Documents\Visual Studio 2013\Projects\OFR\OFR\UploadedImages

What can I do to get the proper path?


Solution

  • It is just spell mistake. you have to write like this

    String path = Server.MapPath("~/UploadedImages/");
    

    which will give your expected path

    C:\Users\DELL\Documents\Visual Studio 2013\Projects\OFR\OFR\UploadedImages

    Instead of UploadImages use UploadedImages.