In my C # class that I wrote, I have a photo property that returns the source of the photo if the image exists (otherwise nothing or the default image). In my code, I use:
public string Photo
{
get
{
string source = "~/images/recipes/" + id + ".jpg";
if (File.Exists(source))
return "~/images/recipes/" + id + ".jpg";
else
return "";
}
}
If I get the FileInfo () information for this image, I see that I'm trying to find this image in the following directory: C: \ Program Files (x86) \ Common Files \ Microsoft Shared \ DevServer \ 10.0 \ ~ \ images \ recipes
Of course, the image is not in this directory, and File.Exists returns me the wrong value. But how can I fix this?
source
share