0

what i want to do is to send images via my Web Api. Until now i was using absolute paths and the method Image.FromFile, then i converted the images into Base64 and everything was working fine. But now i uploaded my project and everything is working fine except for images, because the stored paths are "C:............etc" i tried to use relative paths like "Images/MyImage.png" or "/Images/MyImage.png" or "~/Images/MyImage.png" but nothing worked. How can i fix this ?

PS My problem is the same of this question: IIS virtual directory and ASP.NET directory paths but none of the solutions worked for me

Thank you a lot Regards, Marco

Community
  • 1
  • 1
Marco Cadei
  • 145
  • 2
  • 4
  • 14

1 Answers1

2

Have you tried this?

string root_path = HttpRuntime.AppDomainAppPath;
string image_folder_path = root_path+"images";
/// Use the path
some_name
  • 1,183
  • 8
  • 13
  • Thanks for helping, but where should i use this and how ? – Marco Cadei May 18 '14 at 13:52
  • I am not sure what you mean by that. see if my edit helps you – some_name May 18 '14 at 14:20
  • Man you are the legend !! That worked perfectly ! I wonder how i didn't find an answer like yours before ! Thank you a lot – Marco Cadei May 18 '14 at 14:23
  • yw. I remember I struggled it myself the first time I had this problem, there are so many ways to get the root path but this was the only one I found that act the same in both localhost and real server. – some_name May 18 '14 at 14:29