程式碼
public static bool CheckIfFileIsBeingUsed(string fileName)
{
FileStream s = null;
try
{
s=new FileStream (fileName, FileMode.Open, FileAccess.Read, FileShare.Delete );
return false;
}
catch (System.IO.IOException)
{
return true;
}
finally
{
if (s != null)
s.Close();
}
}
沒有留言:
張貼留言