lock a file
Published: 9. October 2011 | Updated: 31. October 2011License: Microsoft Public License (MS-PL)
Categories: Windows
Tags: C# File System Windows
Import namespace
using System.IO;
Code
using (FileStream fileStream = File.Open(@"C:\test.txt", FileMode.Open, FileAccess.Read, FileShare.None)) { Console.Write("File is locked"); Console.ReadLine(); }
| Send us feedback about this snippet » |





