Your statement is basically correct, but doesn't address what seems to
be the main issue: having to rewrite the entire file to disk once the
new line is added. The same problem is encounter by a file in XML format
as one in plain text format.

The problem is that both FAT32 and NTFS: 
1. tend to store files flush with one another, taking up contiguous
sectors on the storage medium whenever possible.
2. don't have an easy way to determine what is *before* the beginning of
a file on storage short of doing a full scan of the files table on each
write.
3. don't have an efficient way to write multipart files back-to-front.

Short of rewriting the operating system, you'll need to write over the
entire file each time you rewrite. Even appending at the end is usually
more trouble than it's worth.

(On the plus side, disk writes have gotten really, really fast. The
current application on my desk overwrites a 1.7 MB XML-formatted text
file to a standard IDE hard drive too fast for the end user to even
notice it's happening.)

If you're worried about disk writes slowing down your application, you
can do any number of things. Here are two that come to mind:

1. Store your outgoing messages in a stack in memory and only write
every "x" messages.
2. Do your file-writes on a background thread.

--Jekke

-----Original Message-----
From: Discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] On Behalf Of Jon Rothlander
Sent: Friday, November 18, 2005 11:25 AM
To: [email protected]
Subject: Re: [ADVANCED-DOTNET] Writing data to the beginning of a file


Based on his questions, he is not using a windows event log and he seems
to
just be using his own log file design.  Nothing in his post says that he
does or does not have control over the format of the log file.  If so,
he
may be able to use XML.  If that is the case, which we cannot really
tell
unless he lets us know, he could use an XML file to hold the entries.
Using
XML allows for much easier access than a text based log file.  In XML
you
can specify the location that you want to add a new node or element to.
For example...

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to