CSharp examples for File IO:File Command
Is File Locked
using System.Web; using System.Threading; using System.Linq; using System.IO;//from ww w.j av a 2 s .c o m using System.Diagnostics; using System.Collections.Generic; using System; public class Main{ public static bool IsFileLocked(FileInfo file) { FileStream stream = null; try { stream = file.Open(FileMode.Open, FileAccess.ReadWrite, FileShare.None); } catch (IOException) { return true; } finally { if (stream != null) stream.Close(); } return false; } }