0

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?

user3642625
  • 57
  • 1
  • 1
  • 8
  • Is it a big deal really ?! – Moshtaf Aug 01 '14 at 13:43
  • I am using it to upload files. I could add the file directly to database but I wanted to try it this way also. Since the path is wrong, it is throwing an exception. – user3642625 Aug 01 '14 at 13:45
  • Since the paths aren't case sensitive, I imagine your exception (you haven't shown us the code that produces it) is more likely to do with the trailing backslash or lack thereof. – mason Aug 01 '14 at 13:47
  • upload files using .SaveAs(Server.MapPath("~/UploadImages/")+filename) ? I don't think the exception occur by case sensitivity, you can shown us your code to get a detailed help. – Moshtaf Aug 01 '14 at 13:49
  • @Moshtaf sorry for wasting your time. It was really my typing mistake. – user3642625 Aug 01 '14 at 14:01

1 Answers1

0

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.

Krishnraj Rana
  • 6,516
  • 2
  • 29
  • 36
  • Thanks for pointing that out! I literally surfed the net for two hours to try and get the exact path. It worked! – user3642625 Aug 01 '14 at 13:52