Using Logging Files

Zenerdiode

Active Member
Licensed User
In my application I'm continually logging data to the hard drive. However I notice the data is not actually written to the disk until the file is closed. The log files are an hour long but I would like the data written to the disk at least every minute.

Is there a method of purging the buffer and forcing the data write?
 

agraham

Expert
Licensed User
Longtime User
Is there a method of purging the buffer and forcing the data write?
The obvious way is to close and reopen the file. The .NET streams which underly Basic4ppc file handling do have a Flush method which you could call from the Door library but you need a reference to the stream.

If you use the CodePageFile from my BytesConverter library you could get the StreamWriter with Object.FromLibrary using "sw" as the field name and then invoke Object.RunMethod("Flush").

I'm afraid it's not so easy to get the stream of a Basic4ppc opened file as they are held in a hashtable that is only accessible by Reflection. Possible with the Door library but a bit messy!
 
Top