0

Hello,
I have an image in one of my project folders:
Lets say its in: ~/App_Themes/Default/images/SomeImage.png

I want to load this image into a System.Drawing.Image, how do I do that?

If I try using the FromFile method of the Image class:
Image img = Image.FromFile("~/App_Themes/Default/images/SomeImage.png", true);

I get a "FileNotFoundException".
I have read some suggesting to store the image into the Server but that's not an option. Is there any way to load this into the Image?

2
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by GFX010
0

Try using the server.mapPath() method to point to the file location if this is a web project.
This will look for the folder and file in relation to its physical location to the root folder

0

Thanks for the reply but it didn't work, I still get the same FileNotFoundException exception.

0

Can you locate the image using the physical path? i.e. create a image link on your page where the src points to the image? If you can't then you may need to verify the image location and name.

0

I can locate the image using the physical path but for some resaon when I use the Image.FromFile method an Exception occurs.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.