Wrox Programmer Forums
|
Pro VB.NET 2002/2003 For advanced Visual Basic coders working .NET version 2002/2003. Beginning-level questions will be redirected to other forums, including Beginning VB.NET.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 24th, 2005, 09:25 AM
Authorized User
 
Join Date: Dec 2004
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to eelisMX
Default Circular appending LOG file

Hi

I keep track of my application by writing to log file using StreamWriter(append=true).
I'd like to have a limit for the file size. Once the file gets to the limit, the new entry would overwrite the oldest one in the beggining of the file (the oldest is then removed for good).

This kind of circular file appending happens for example on the log file of the Scheduled Tasks Folder(C:\WINNT\SchedLgU.txt).


Is there a neat way of doing this circular appending ?

Thanks!
 
Old February 24th, 2005, 12:20 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

You could treat the log file as a datasource instead of a stream, and then use the .delete method.

When the record cout got to be at the max size, prior to adding a new entry (which would cause a size of Max + 1), .MoveFirst, then .Delete, then do your addition of a new record.
 
Old February 25th, 2005, 04:42 AM
Authorized User
 
Join Date: Dec 2004
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to eelisMX
Default

Thanks Brian

Could you please give a short example of how to treat the log file as datasource.

Thanks!
 
Old February 25th, 2005, 01:22 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

I have never actually done this, but I have read often that ADO.net (as was the case with ADO, I believe) can utilize text files as a data source.
I hate using VisualStudio help, but I'm sure there are some samples in there.

Make another posting if you are unable to find anything on it, and I’ll see if I can find something.
 
Old March 1st, 2005, 06:30 AM
Authorized User
 
Join Date: Dec 2004
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to eelisMX
Default

I found some information about Microsoft Text Driver that connects to .txt and .csv files and treats them as datasource.
In my application, the .txt log file is displayed within a multiline textbox (which as far as I know don't have a datasource member).

Anyway, I'm looking for an alternative way to save and display the log file. XML is my main focus since I worked with it before, and the data manipulation is much easier.
BTW, is there any size limit when loading an xml file into XMLDocument object (or the only problem is the cost in processing time) ?





Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't get Log to write the Log.txt file jnbutler BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6 3 July 31st, 2007 04:04 AM
Appending child nodes to a RDF/OWL file using xslt sesath XSLT 2 May 10th, 2007 04:37 AM
Appending to the middle of a file monuindia2002 XML 4 March 8th, 2006 05:21 AM
Log file tsimsha Classic ASP Databases 1 April 30th, 2005 04:27 AM
Log file Asish SQL Server 2000 3 November 10th, 2003 02:30 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.