4
How do I know if a file is blocked or not? I have perfected this code and I would like to know from you whether it is correct or for the better. Another question is if it is corrupted, the check below is valid?
public bool IsFileLocked(FileInfo file)
{
FileStream stream = null;
try
{
stream = file.Open(FileMode.Open, FileAccess.ReadWrite, FileShare.None);
}
catch (IOException)
{
return true;
}
finally
{
if (stream != null)
stream.Close();
}
return false;
}
This might help: http://stackoverflow.com/questions/1304/how-to-check-for-file-lock later I try to write a reply. BTW +1.
– Oralista de Sistemas