Solved

reading a text file from windows service

Posted on 2004-09-21
5
206 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Specific format 21 197
groovy example issue 10 97
Definitions and default visual studio colors 5 65
egit plugin on eclipse 8 63
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
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 …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

773 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