 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Guest
|
Posted: Tue Jan 30, 2007 9:12 am Post subject: append log at the start of the file |
|
|
I want to append the log details(messages) at the start of the file
each time.
we have eof , is any option for start of file.
can anyone pls help me |
|
| Back to top |
|
 |
Guest
|
Posted: Wed Jan 31, 2007 3:12 am Post subject: Re: append log at the start of the file |
|
|
On Jan 29, 10:58 pm, anandarama...@gmail.com wrote:
| Quote: | I want to append the log details(messages) at the start of the file
each time.
we have eof , is any option for start of file.
can anyone pls help me
|
You're basically making a new file each time for something like this.
You aren't appending information; you're inserting. If you're using a
TFileStream, then any writing will overwrite existing data. One option
is to load the file into a TStringList and Insert() your entries at a
0 position. Aside from that, if you are using lower level routines
then you'll want to look at making a temporary file, writing your
contents, then copying over the contents of the existing log file.
This method is doing essentially the same thing as the TStringList
method; except that it's just using a different method to buffer the
file. The downfall of the TStringList method is that you'd be loading
the entire log file into memory; so you may want to just stick with
the lower level routines so you can copy it by chunks.
The question you may also want to ask, is whether or not you really
need to insert your log entries at the top. Why not just write the log
file normally, but read it in reverse? I imagine you're going to be
writing to the log file a lot more than you would be reading it; so
save the more time consuming methods and routines for the event that
happens the least.
-- Michael |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|