public static void ForceDeleteFile(string path) { if (File.Exists(path)) { using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read)) { stream.Dispose(); } File.Delete(path); } }