I have a windows application with an “images” folder. I need to check if an image exists, which it will, during runtime. The below code is what I have but it always returns false.
if ( File.Exists("images/" + item.tool_image) )
{
Image img;
img = Image.FromFile("images/" + item.tool_image);
titem.Image = img;
}
Whats the problem or the proper way to do this.
If the file you’re looking for doesn’t exist in the working directory of your application, call
File.Existswith a fully-qualified path:Of course, verify that a file actually exists at that location.
You’ll find life easier if you use the tools provided by the
Pathclass: