I want to check if a file exists. So, if I have a file name of
'C:\MyDir\MyFile.ext' and I want to check if it exists, what is the
easiest/shortest code way? I can loop through the directory, but I figure
there must be a more direct way. Also, I'd like to be able to check for
existence of *any* files with a particular extension in a given directory. I
tried using the System.IO.FileInfo class, but I can't figure out how to
point it toward a filename.
Code is most appreciated.
I am presently using the System.IO.Directory object (.GetFiles member) to
loop through and identify files. It works, but seems cumbersome.