/// <summary>
/// Gets a value indicating if the FileSystemInfo object is currently available
/// </summary>
/// <param name="fsInfo"></param>
/// <param name="recordedSerial">if a serial is specified the return value is more reliable.</param>
/// <returns></returns>
public static bool IsAvailable(FileSystemInfo fsInfo, string recordedSerial)
{
// Get Drive Information
DriveInfo driveInfo = GetDriveInfo(fsInfo);
// Refresh the object information (important)
fsInfo.Refresh();
// Check if the file exists
bool fileExists = fsInfo.Exists;
// Do we have a logical volume?
if (driveInfo != null && fileExists)
{
string currentSerial = driveInfo.GetVolumeSerial();
// if we have both the recorded and the current serial we can do this very exact
// by checking if the serials match
if (!String.IsNullOrEmpty(recordedSerial) && !String.IsNullOrEmpty(currentSerial))
// return the exact check result
return (currentSerial == recordedSerial);
}
// return the simple check result
return fileExists;
}