Easiest way to read text file which is locked by another application
I think you just want the following: using (var fileStream = new FileStream(“foo.bar”, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) using (var textReader = new StreamReader(fileStream)) { var content = textReader.ReadToEnd(); } The FileAccess.Read parameter is what is important, to indicate that you only want to read the file. Of course, even to do this, the file must have … Read more