On 8/30/02 12:15, Steve Schacht wrote:
> Let's say I have a valid reference to a FolderItem for a document that's
> currently being edited by a user. This document has already been saved
> previously. So then the user makes some changes, and the dirty flag is set.
> Now the user selects "Save". When I save the document, I'm writing out the
> entire file (as a text stream) each time. My question is... Should I be
> deleting the existing file before saving? My testing has indicated that
> this is not necessary - i.e. that I can just re-open the text stream and
> overwrite what's there - but I wanted to know if this is bad practice for
> any reason.
Some people have reported write failures if they don't delete first, so to
be safe I always delete the file if it exists, and I'm replacing its entire
contents. The apparent reason (as I understand it)for a failure with a text
file is that you're using .CreateTextFile, which doesn't always seem to work
properly if the file already exists. (It would be nice if OpenAsTextFile had
read/write parameters like OpenAsBinaryFile does.)
For binaries there doesn't seem to be a problem, because for those you
usually aren't using .CreateBinaryFile when the file already exists. And, of
course, .AppendToTextFile isn't a problem, for the same reason.
George
--
George Clark - gaclark at sprynet dot com
|