public static Boolean IsFileLocked(FileInfo file) { FileStream stream = null; try { stream = file.Open(FileMode.Truncate, FileAccess.Write, FileShare.None); //using (StreamReader reader = new StreamReader(File.Open(filePath, FileMode.Open, FileAccess.ReadWrite))) //{ // return false; //} } catch (IOException) { return true; } finally { if (stream != null) stream.Close(); } return false; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)