Solved

File I/O operations

Posted on 2000-02-17
5
210 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
Comment Utility
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
Comment Utility
FindFirstChangeNotification() is a windows API function.

vesel, are you using windows?
0
 

Author Comment

by:vesel
Comment Utility
I am on Win2000 using vc6
Need code folks please help asap

Thx a lot
0
 
LVL 22

Expert Comment

by:nietod
Comment Utility
Then ufolk123's suggestion will work.
0
 

Author Comment

by:vesel
Comment Utility
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

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

772 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

10 Experts available now in Live!

Get 1:1 Help Now