Well naturally you can not replace an existing file. So move the existing file
somewhere else, or
rename the existing file. Then once you're sure the new file is in place,
delete the old one.
Renaming can be messy, so I'd suggest moving.
I'm dealing with the same sort of thing in my ImagePlay app. That line to keep
the creation date
is smart, I didn't think of that.
~ Tomis
--- Adam Ernst <adam1234 at athenet dot net> wrote:
> 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>
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
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>
|