[DUG] Renaming file in use
John Bird
johnkbird at paradise.net.nz
Fri Dec 2 16:46:01 NZDT 2005
I doubt RenameFile would work reliably for programs...for instance it would
be sensitive to OS and Windows versions. If it does allow it its because
the file presumably is small enough to have been loaded entirely into memory
or that is what the OS has done.
Unless later versions have changed, according to the D5 help the function
will fail anyway if the newfilename already exists. (You may have to copy
the file instead).
"function RenameFile(const OldName, NewName: string): Boolean;
Description
RenameFile attempts to change the name of the file specified by OldFile to
NewFile. If the operation succeeds, RenameFile returns True. If it cannot
rename the file (for example, if a file called NewName already exists), it
returns False."
Offtopic Nostalgic thought (sigh) Unix handles renaming files in use much
better. It allows it no problem. Any files with the old version open still
access the old data file which is preserved until closed. When reopened it
gets the new version. Very transparent. Windows just doesn't allow it,
even if the file is only open read-only. If I remember VMS did something
even smarter with maintaining multiple versions of files as part of the
filesystem.
The scheme I use is for programs.
John
-----Original Message-----
From: delphi-bounces at ns3.123.co.nz [mailto:delphi-bounces at ns3.123.co.nz] On
Behalf Of Jeremy Coulter
Sent: Friday, 2 December 2005 2:18 p.m.
To: 'NZ Borland Developers Group - Delphi List'
Subject: RE: [DUG] Renaming file in use
I just used the "RenameFile" function. This is D7
Jeremy
-----Original Message-----
From: delphi-bounces at ns3.123.co.nz [mailto:delphi-bounces at ns3.123.co.nz] On
Behalf Of Robert martin
Sent: 2 December 2005 14:12
To: NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] Renaming file in use
This is no help but... How do you do it in Win2K and above?
Rob Martin
Software Engineer
phone +64 03 377 0495
fax +64 03 377 0496
web www.chreos.com
Wild Software Ltd
Jeremy Coulter wrote:
> Hi All. I am sure I have seen this mentioned before, but I has as part
> of an app. the ability to auto update. part of the update process is,
> it needs to rename the current running app. to .old. this this fin
> under win2K onwards, but on winnt and win98, it throws an error.
>
> Is there a work around? I did a search on Google, but not a lot came
> back....but that could have been how I was searching too.
>
> Jeremy
>
> --
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.1.362 / Virus Database: 267.13.10/190 - Release Date:
> 01/12/2005
>
>-----------------------------------------------------------------------
>-
>
>_______________________________________________
>Delphi mailing list
>Delphi at ns3.123.co.nz http://ns3.123.co.nz/mailman/listinfo/delphi
>
>
_______________________________________________
Delphi mailing list
Delphi at ns3.123.co.nz http://ns3.123.co.nz/mailman/listinfo/delphi
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.10/190 - Release Date: 01/12/2005
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.10/190 - Release Date: 01/12/2005
_______________________________________________
Delphi mailing list
Delphi at ns3.123.co.nz http://ns3.123.co.nz/mailman/listinfo/delphi
More information about the Delphi
mailing list