I've looked at several solutions to reading a file that's already in use by another process, but none of them seem to work for me.
The file I'm trying to read is an XML file that contains configuration settings that I need to extract.
Here's what I have tried:
using (var stream = File.Open("\\\\2008r2\\c$\\ProgramData\\location\\siteConfig.xml", FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var reader = new StreamReader(stream))
{
// Actions you perform on the reader.
while (!reader.EndOfStream)
{
Console.WriteLine(reader.ReadLine());
}
}
This seems to work for just about everyone else, I don't know what I'm doing wrong! Is my file locked in a different manner and cannot be accessed even to read?
Help much appreciated!
Dave