Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Determine UNC Path from a Drive Letter?
Message
 
À
07/08/2002 19:38:51
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00687141
Message ID:
00687453
Vues:
16
>I attempted to test this from the command window and I get an error "Invalid index". Using Foxpro 7 and XP Pro.
>
John,

It's probably caused by my giving you a poor example. Here's a function that'll return the drive based on the UNC passed.
FUNCTION FindDrive

LPARAMETER tcUNC && The UNC to find

LOCAL lnlast, lni, loNet, loDrives, lcresult, llfound
lcresult = ""
llfound = .F.
loNet = CREATEOBJECT("WScript.Network")
loDrives = loNet.EnumNetworkDrives
lnlast = loDrives.Count 
lni = -1
DO WHILE lni < lnlast AND NOT llfound
  lni = lni + 2
  llfound = (UPPER(tcUNC) = UPPER(oDrives.Item(lni)))
ENDDO
IF llfound
  lcresult = oDrive.Item(lni - 1)
ENDIF
RETURN lcresult
Note that the offset is zero based rather than one based. For example, if the Count property returns 2, the indexes are 0 and 1.
George

Ubi caritas et amor, deus ibi est
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform