Read Changes on a text file dynamically c# -
i have program continuously writes log text file. don't have source code of it, can not modify in way , protected themida.
i need read log file , execute scripts depending on content of file. can not delete file because program continuously writing has locked file. better way read file , read new lines of file? saving last line position? or there useful solving in c#?
perhaps use filesystemwatcher along opening file fileshare (as being used process). hans passant has provided nice answer part here:
var fs = new filestream(path, filemode.open, fileaccess.read, fileshare.readwrite); using (var sr = new streamreader(fs)) { // etc... } have @ question , accepted answer may help.
Comments
Post a Comment