>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 loDrive
s as loDrive.
Sorry for the inconvenience. Corrected code below.
FUNCTION FindDrive
LPARAMETER tcUNC
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