I have to check if a set of file paths represent an existing file.
It works fine except when the path contains a network share on a machine that\'s not on the curren
Another "thread solution":
/// Check if file exists with timeout
/// source
/// The number of milliseconds to wait,
/// or (-1) to wait indefinitely.
/// Gets a value indicating whether a file exists.
public static bool Exists(this FileInfo fileInfo, int millisecondsTimeout)
{
var task = new Task(() => fileInfo.Exists);
task.Start();
return task.Wait(millisecondsTimeout) && task.Result;
}
Source: http://www.jonathanantoine.com/2011/08/18/faster-file-exists/
There are some concerns about "drive not responding fast enough", so this is compromise between speed and "the truth". Don't you use It if you want to be sure 100%.