Tailing a text file with VB.NET

whizbang

New member
Joined
Dec 14, 2003
Messages
1
Location
QLD, Australia
Im very new to VB.Net, and have done a bit of googling for info on the subject, but was only able to turn up some stuff on VB6 which didnt seem too helpful or relevant with .NET

Basically what I want to do is write a small program to read data from a legacy Windows app for managing point of sale terminals.

The app starts writing a new text file every day. During the day as sales occur at a POS terminal, the data flows to this Windows app which then writes the data out to a text file.

I need to figure a way to open the text file for reading, process each line or transaction and get out the data I want, and then stay waiting with the file open and waiting for new data... doesnt have to be realtime, but it would be nice to keep any delay of new data written to the text file and read by my program to a minimum.

A thought I had was maybe once finished processing the file, keep a note of its filesize, and then keep checking every second if the size has changed, if so then read in the new data in the file.

As I say tho, Im new to VB and really unsure of what it offers... Ive got some VB.Net books on the way (hopefully arrive next week) to help me.

Does anyone have some code that might do what Im after or be able to point me in the right direction as to how to achieve what I want?

Cheers
 
Check out the StreamReader and StreamWriter classes. Utilizing these two and all of the text string properties and methods should give you a good start.
 
Back
Top