I am trying to check if a file is in use. The below code works, but after I run it the first time, it locks the file so that it always returns that the file is in use.
How do I check if the file is in use but also not keep the file open after I check?
try
{
File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.None);
}
catch (Exception exp)
{
return true;
}
return false;
Thanks,
Jerry