Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Testing if a file is in use
Message
From
03/07/2003 10:57:25
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
03/07/2003 10:38:52
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00806551
Message ID:
00806563
Views:
16
>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)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform