This is the way I check to see if any file is open before working on it.
private bool IsFileLocked(FileInfo file)
{
FileStream stream = null;
try
{
stream = file.Open(FileMode.Open, FileAccess.ReadWrite, FileShare.None);
}
catch (Exception)
{
return true;
}
finally
{
if (stream != null)
stream.Close();
}
return false;
}
Then call it like.
if (IsFileLocked(new FileInfo(dwgName)))
{
}