I am trying to validate if an image name fetched from my database exists in a directory. example:
if(imagen001 ==ruta\xx\imagen001)
{
mensaje: Si tiene imagen
}
In this case I'm going to have many image names in the database as well as in my images folder.
You could load the images into a list in memory using
the idea of
Select()
is to get the names of the files since itGetFiles()
does not give the full paththen after you iterate the data from the db
If you have the path and file name independently you can do the following:
Remember to include at the beginning of your file:
If what you want to know is if a path given as a string contains the name of a specific file, you can do the following:
The latter could be done with the IndexOf function that the strings have, but you should check that the position found is the last possible one, that is:
If you want to search for exactly the same file name, case sensitive; you can remove the .ToLower() wherever it appears in the last example, that is, it would look like this: