Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Existence of a folder?
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00006381
Message ID:
00006391
Views:
44
>How to check if a folder exists already

Try this:
DECLARE integer FindFirstFile IN Win32API AS FindFirst ;
  STRING @lpfn, STRING @lpfbuf
lpfbuf = space(512)  && just to be on the safe side
lpfn = 'C:\WINDOWS'  && this is the directory name we're looking for
h = FindFirst(@lpfn, @lpfbuf)
IF (h = -1)
  ? "We know it's not there"
ELSE
  ? "We now have to figure out if it's really a folder or just a file."
  IF BITAND(Asc(SubStr(lpbuf, 1, 1)), BITNOT(16))
    ? "This, according to my research means it's a folder"
  ELSE
    ? "If that bit wasn't set, then it's not a folder"
  ENDIF
ENDIF
Alternatively, you could try one of the techniques discussed a long time ago about trying to figure out if a removable drive (floppy disk) was there and writeable -- by going ahead and trying to create a file then simply trapping any I/O errors transparently.

Unfortunately, this has been tested only on 32-bit Windows.
Hope this helps!
alistair israel
Distressed DBA, Sleepy SysAd, Weary WebMaster (aka Senior Software Engineer)
aisrael@poboxes.com
Makati City, Philippines
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform