Information générale
Titre:
Directory() & Diskspace()
Ignore if already known:
I have a removable 120Gb Firewire drive on my notebook hanging off an IEEE 1394 PCMCIA card. It's usually drive E: on my Win2000 system and Windows Explorer says it's an NTFS 'Local Disk'.
When I dismount the drive, and remount it, Windows Explorer frequently continues to show the old drive letter as if it was still in use, this time as a 'Removable Disk', and assigns the real drive a new letter, say G:
At this point, in VFP8:
DIRECTORY("E:") misleadingly returns .T.
DRIVETYPE("E:") misleadingly returns 3 && DRIVETYPE_HARDDISK
DISKSPACE("E:") correctly returns -1
I would advise all to pretest the drive letter with DISKSPACE() before looking to see whether a folder is present with DIRECTORY().
One further thing: DISKSPACE() returns .F. if passed a folder path starting with a valid drive letter, where the folder doesn't exist.
So the really safe tests for folder and drive types are:
#DEFINE DRIVETYPE_NONE 1
#DEFINE DRIVETYPE_FLOPPYDISK 2
#DEFINE DRIVETYPE_HARDDISK 3
#DEFINE DRIVETYPE_REMOVABLE_OR_NETWORK 4
#DEFINE DRIVETYPE_CDROM 5
#DEFINE DRIVETYPE_RAMDISK 6
Folder exists:
IIF(DISKSPACE(JUSTDRIVE(cPath))>0, DIRECTORY(cPath), .F.)
Drive type:
IIF(DISKSPACE(JUSTDRIVE(cPath))>0, DRIVETYPE(cPath), DRIVETYPE_NONE)
FYI
John Burton
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement