Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Check to see if a file is open
Message
From
09/05/2007 16:19:42
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01223969
Message ID:
01223977
Views:
14
>How do you check to see if a file is open without attempting to open it first?
>
>I looked at FOPEN(cFileName, nAttribute) and wonder if this would do the job, or is there more to this? I have done this a long time ago, I think.

The reason TRY/CATCH as Nadya suggests (or ON ERROR in older versions) is best is that too many things can go wrong when interacting with any resource external to your program, like files on disk. For example:
  • The file may be used by another person.
  • The file may be R/O. This includes files on a CD.
  • You may not have enough privileges for the folder or file.
  • When adding records, disk may be full.

    ... and probably a few more.
    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
    Reply
    Map
    View

    Click here to load this message in the networking platform