Sometimes you need to check the existence of a file. Nothing is easier with the .Net framework which provide a property named Exists on FileInfo class.
But it can be quite long, especially when the file is on a network drive. If so you’ll have to wait for a time-out to know that the file is not reachable.
This was too slow for me so I coded this little utility which performs the same but with a customizable TimeOut. As it may interest you, here it is:
[csharp]private static bool VerifyFileExists(Uri uri, int timeout)
var task = new Task<bool>(() =>
var fi = new FileInfo(uri.LocalPath);
return task.Wait(timeout) && task.Result;