Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Decided I would get back in to programming a bit just to keep my brain from going numb from playing too many video games :). Haven�t done any programming at all in several years (since VB3), and just sort of played at it back then. I thought I would start with something simple, but it�s turned out to be more complicated than I originally thought. I just picked up VB.net this morning so bear with me.

 

What I am trying to do is read a text log file as it is being written to disk, and parse the information in it. The log files can be rather large (from 1 to over 100 megabytes), and I am not interested in any of the information except for the new lines as they are being written. The plan was to load the log file when the progam starts, just to get passed the information that I don�t need, then read each new line when a FileSystemWatcher event goes off. Does this sound like the right way to go about this?.

 

My problem is that I can�t seam to figure out how to make this work without reading in the entire file every time I get a FileSystemWatcher event.

 

Not looking for someone to write this for me, just a push in the right direction :)

  • *Experts*
Posted

Assuming the file is getting updated and NOT held open (which might cause problems when your program opens it), you could do just as you suggested: read the file in once OR just get it's length (not quite sure how - FileLen() in VB6 though :)). On subsequent calls, seek to that position and begin reading til end of file.

 

At least in theory this should work :)

 

-ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted

Thanks for the reply. I guess my next question would be is it possible to declare a file stream globally? If I create it in the FileSystemWatcher event I have to load the entire file in each time the event fires.

 

Thanks

Posted
Was able to figure out what I needed to do. It was easy once I realized I could still use the old style file functions in VB.net. I�m sure it is doable using the IO functions, but I don�t have a good reference for them, and the help files are pretty bad. I guess it would help if I had the VB.net manuals, but I bought the version that came with the step by step book. :/

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...