shahzad73
asked on
reading a text file from windows service
Hi
I have developed a windows service which monitors the text file. Windows service checks the file 2 times in a second depending on the frequency it is set.
I want to know how to detect whether a new line is added or multiple lines has been added. If added then I want to read those lines.
My windows service has a timer that triggers every 2 times in a second.
any code will be highly appriciated.
Shahzad Aslam
I have developed a windows service which monitors the text file. Windows service checks the file 2 times in a second depending on the frequency it is set.
I want to know how to detect whether a new line is added or multiple lines has been added. If added then I want to read those lines.
My windows service has a timer that triggers every 2 times in a second.
any code will be highly appriciated.
Shahzad Aslam
ASKER
deepak
but i want to use this in windows service while this component raises events. where will i get the event in windows service
Shahzad
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
hi deepak
can you tell me how .net can open a file for reading while it is being opened by another process.
Shahzad
can you tell me how .net can open a file for reading while it is being opened by another process.
Shahzad
Hi Shahzad:
You do not need to open a file to check its change. The FileSystemWatcher has an event handler which
System.IO.FileSystemEventA rgs e
(This has members like name of the file changed in the path being modified).
You do not need to open a file to check its change. The FileSystemWatcher has an event handler which
System.IO.FileSystemEventA
(This has members like name of the file changed in the path being modified).
You can use the FileSystemWatcher in C#:
http://www.c-sharpcorner.com/3/FSWatcherMB.asp
deepak