Solved

File I/O operations

Posted on 2000-02-17
5
246 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
typedef std::deque<BYTE> ByteVector is broken in vs2012 23 89
Find Visual Studio Tools 2 121
Create a path if not exists 7 105
trigs fail! I thought I knew how to do trignometry 3 82
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
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.

680 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