Solved

File I/O operations

Posted on 2000-02-17
5
223 Views
Last Modified: 2010-04-02
Hi Folks! I am having trouble reading a file over the network. The problem is that this file is constantly growing and I wanna read the new(last) lines coming in this file as a result.
The transmission to this file is not constant, sometimes there is a delay until the data comes and gets written to it. Can anyone tell me how to achieve this goal(Code Please)
Eg File at 10:00am looks like
"Hello Brother"
at 10:11am looks like
"Hello Brother"
" How are you Brother";
I have read the first line so this time I wanna capture the last line which is " How are you Brother" only. Hope this lets u understand better.
TIA
0
Comment
Question by:vesel
  • 2
  • 2
5 Comments
 
LVL 3

Accepted Solution

by:
ufolk123 earned 100 total points
ID: 2533595
You can have a logic like this.

You can register a notigication by using

FindFirstChangeNotification()

So whenever the file changes you will get a notification , So you would not have to do a polling on the file.
After each time data is written to the file , you open the file , lseek to the end and go backward for a newline.( I assume the writers to file write line by line).

This is a sample flow of operations.
If you have any doubts please get back.

0
 
LVL 22

Expert Comment

by:nietod
ID: 2534627
FindFirstChangeNotification() is a windows API function.

vesel, are you using windows?
0
 

Author Comment

by:vesel
ID: 2535836
I am on Win2000 using vc6
Need code folks please help asap

Thx a lot
0
 
LVL 22

Expert Comment

by:nietod
ID: 2535973
Then ufolk123's suggestion will work.
0
 

Author Comment

by:vesel
ID: 2547083
Folks i need code to give you 100 points. I know the algo pretty much I wanna see it running.

THx and appreciation.
Vesel
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

932 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

21 Experts available now in Live!

Get 1:1 Help Now