CSharp examples for File IO:File Command
Is File In Use
using System.IO;//from w w w . ja v a 2s. c om using System; public class Main{ public static bool IsInUse(this FileInfo file) { FileStream stream = null; try { stream = file.Open(FileMode.Open, FileAccess.ReadWrite, FileShare.None); } catch (Exception) { //the file is unavailable because it is: //still being written to //or being processed by another thread //or does not exist (has already been processed) return true; } finally { if (stream != null) stream.Close(); } return false; } }