Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Directory() & Diskspace()
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Directory() & Diskspace()
Divers
Thread ID:
00913175
Message ID:
00913175
Vues:
54
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
Fil
Voir

Click here to load this message in the networking platform