Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Alternate to Rename command
Message
De
10/10/2005 14:40:16
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
À
10/10/2005 09:36:45
Steven Dyke
Safran Seats USA
Texas, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 6 SP5
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Divers
Thread ID:
01057642
Message ID:
01057736
Vues:
10
>Is there an alternate way to 'Rename' a file other than Rename command? I need somthing that will return a value as to wheather it worked or not, or haow to trap for errors and return a message to user. I have error trapping that logs the error and returns control backto the program but the user never knows the routine failed. This happens when the renamed from file is open or the rename file to already exists.

I've had this problem with some files (Excel sheets) that need to be generated regularly, and it was happening that someone would have a few of them open. The first part of the process was to move them all into archive directory - and of course the open ones couldn't be moved.

I basically tried to open them low-level, and if fopen() returned -1, a-ha, someone's got you open. I wouldn't even try to rename that file, I'd just copy it (using strtofile(filetostr(oldname), newname), which works for files someone has open.

Then (if the user had the rights to override), I'd go on creating new files, and for the old ones that were still there, I'd try in a loop to name them forceext(oldname+"_01", "xls"), then with "_02" etc. So the new file would be written there, the old would eventually be moved (mostly next time) and I still had all the files archived.

The whole thing changed recently, I'm creating a new directory each time, so the problem completely vanished.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform