Hello,
I have a Text file that a product writes its logs on it, i want to build an application that writes the new logs on database, so i want my application to open this file for read always, the problem is that an exception would fires if the product tries to write on it because it is opened for read, how could i solve that?
Loading
Pravin PatilPosted Sep 14, 2012, 11:36 AM
FileStream stream = new FileStream(@"FileName", FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)
When you are opening a file for Reading only, then you should open it in Read accese mode -
FileStream stream = new FileStream(@"FileName", FileMode.Open, FileAccess.ReadWrite, FileShare.Read)
Hope this helps.
All the best.