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?

Recommended Answers

All 4 Replies

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

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

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.