Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Determine UNC Path from a Drive Letter?
Message
 
To
07/08/2002 19:38:51
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00687141
Message ID:
00687453
Views:
17
>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform