Reputation: 8285
I have a program that populates an asp:repeater. The images show up with the following code
image.ImageUrl = "~/upload/max/" + product.Image1.ToString();
But when i try using
System.Drawing.Image FullsizeImage =
System.Drawing.Image.FromFile(image.ImageUrl);
i get a filepath error saying there is no file there.
Any ideas?
Upvotes: 2
Views: 4175
Reputation: 263047
That's because Image.FromFile() takes a file name, not an URL.
If that code runs on your web server, you can use HttpServerUtility.MapPath() to obtain the path to the physical file from its URL:
using System.Drawing;
using System.Web;
Image fullSizeImage = Image.FromFile(Server.MapPath(image.ImageUrl));
Upvotes: 2