I would create a function something like this:
public static bool TryOpenRead(this System.IO.FileInfo file, out System.IO.FileStream fileStream)
{
fileStream = null;
try
{
fileStream = file.OpenRead();
return true;
}
catch (System.IO.IOException ioException)
{
}
return false;
}
Which, of course, is an extension method for
FileInfo[
^].
Thats at least the only reliable way to both see if the file is available for reading AND get the file at the same time.