Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Testing if a file is in use
Message
De
03/07/2003 10:57:25
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
03/07/2003 10:38:52
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00806551
Message ID:
00806563
Vues:
17
>If I delete a file and this one is used by an other application an error occur. It's possible to know trough a VFP or API function if a file is used by an other application?
>
>Thanks
>david

Yes, you could open the file with fopen(). If this returns -1, the file is used elsewhere.

You could also just use error handling with the command that deletes the file. A simple example follows.
local llError, lcOnError
lcOnError = on("error")
on error llError = .T.
erase MyFile.xyz
on error &lcOnError
if llError
  MessageBox("Can't erase the file for some reason.")
endif
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform