realbasic-nug
[Top] [All Lists]

Safe File Saving

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Safe File Saving
From: Adam Ernst <adam1234 at athenet dot net>
Date: Tue, 31 Jan 2006 19:39:18 -0600
Delivered-to: realbasic-nug at lists dot realsoftware dot com
I'm trying to save a file the 'safe' way, by creating a temporary file, saving the data to there, and then moving that temporary file on top of the existing file. But on Windows, I get error 183, "file already exists". Here's my code:

  if oldFile.Exists then f.CreationDate = oldFile.CreationDate
// oldFile probably exists. But I don't want to delete it first-- that would sacrifice safety.
  f.MoveFileTo oldFile
if f.LastErrorCode <> 0 then return false // LastErrorCode=183, "file already exists"

Any suggestions? What's the "proper" way to do this?

Thanks,

Adam Ernst

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>