Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need to open file I log to but get file locked exception

Tags:

c#

log4net

hI,

I'm using LOG4NET to log to a txt file. However, one of my forms needs to open the txt file (using streamreader) to read the contents and display them in a .txt file. However, I keep getting an exception stating that the file is locked by another process.

Is there a way around this in LOG4NET?

Thanks

like image 256
blade44 Avatar asked Apr 06 '11 08:04

blade44


2 Answers

This may be help you.

http://www.ericbt.com/Blog/48

like image 64
Jayantha Lal Sirisena Avatar answered Sep 20 '22 19:09

Jayantha Lal Sirisena


If you open the log file with ReadWrite sharing enabled (FileShare.ReadWrite) it will probably work.

You can always uses Process Monitor from http://www.sysinternals.com to see what is happening.

like image 26
Nick Randell Avatar answered Sep 21 '22 19:09

Nick Randell