2009-08-14 76 views

回答

6

像这样的东西应该工作:

public bool FileIsLocked(string fileName) 
    { 
     FileStream fs; 
     try 
     { 
      fs = File.Open(fileName, FileMode.OpenOrCreate, FileAccess.Read, FileShare.None); 
      fs.Dispose(); 
     } 
     catch (IOException) 
     { 
      return true; 
     } 
     return false; 
    } 
0

你可以尝试打开此拒绝其他应用程序访问它。

当你得到异常,你会知道这个文件被其他人使用。