Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Determine UNC Path from a Drive Letter?
Message
 
À
08/08/2002 11:44:56
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00687141
Message ID:
00687582
Vues:
14
>Sorry I can't get this to work. It is the loDrives object that appears to have nothing in it. The loDrives.count reports 2 but I have five (assuming that loDrives.count reports the number of drives). But it errors out on loDrives.item.
>
>Below is my test prg. I changed oDrives to loDrives in your example. I'm running XP and VFP7:
>
>myresult=finddrive("\\homesrv\srv-f")
>SET STEP ON
>return

John,

Doh! There are two typos not one. The first, that you noted, was that I initialized loDrives, and then referenced it as oDrive. The second was referencing what should've been loDrives as loDrive.

Sorry for the inconvenience. Corrected code below.
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(loDrives.Item(lni)))
ENDDO
IF llfound
  lcresult = loDrives.Item(lni - 1)
ENDIF
RETURN lcresult
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