Solved

reading a text file from windows service

Posted on 2004-09-21
5
204 Views
Last Modified: 2010-04-17
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
0
Comment
Question by:shahzad73
  • 3
  • 2
5 Comments
 
LVL 15

Expert Comment

by:deepaknet
ID: 12110425
Hi:

You can use the FileSystemWatcher in C#:

http://www.c-sharpcorner.com/3/FSWatcherMB.asp

deepak
0
 
LVL 1

Author Comment

by:shahzad73
ID: 12110538

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
0
 
LVL 15

Accepted Solution

by:
deepaknet earned 50 total points
ID: 12110607
0
 
LVL 1

Author Comment

by:shahzad73
ID: 12110742
hi deepak

can you tell me how .net can open a file for reading while it is being opened by another process.



Shahzad
0
 
LVL 15

Expert Comment

by:deepaknet
ID: 12110819
Hi Shahzad:

You do not need to open a file to check its change. The FileSystemWatcher has an event handler which

System.IO.FileSystemEventArgs e

(This has members like name of the file changed in the path being modified).
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
maxMirror challenge 10 88
bunnyEars challenge 6 62
Exe program is not a valid Win 32 application 15 95
word0 challenge 3 56
RIA (Rich Internet Application) tools are interactive internet applications which have many of the characteristics of desktop applications. The RIA tools typically deliver output either by the way of a site-specific browser or via browser plug-in. T…
I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now