Board index » Visual Studio » validating network path
|
NoSpam-jmuehe
|
|
NoSpam-jmuehe
|
validating network path
Visual Studio151
I know how to validate a standard local path (ie. c:\windows), but I am not having luck validating a path such as (\\server\dir\dir). Could someone point me int he right direction? Thanks!! -- -------- Jon - |
| Jon
Registered User |
Tue Sep 16 09:09:16 CDT 2003
Re:validating network path
Figured it out...
Dim fso As New FileSystemObject, b as Boolean b = fso.FolderExists("\\server\path\dir") "Jon" <ruffles_@msn.com>wrote in message QuoteI know how to validate a standard local path (ie. c:\windows), but I am - |
| Al
Registered User |
Tue Sep 16 09:32:05 CDT 2003
Re:validating network path
The FileSystemObject is meant for scripting. It requires an additional
reference in the application. If distributed you will find that there are many versions out there. It is also slower that most API or native VB approaches. Most of the regulars here will advise against using the FileSystemObject. My way may not be the best... I'm sure you will get other replies and suggestions. Al Reid "Jon" <ruffles_@msn.com>wrote in message QuoteThanks for that api method. Do you think it is more reliable than the - |
| Karl
Registered User |
Tue Sep 16 15:21:29 CDT 2003
Re:validating network path
Hi Jon --
QuoteI know how to validate a standard local path (ie. c:\windows), but I were doing that right. <G> Public Function IsDirectory(ByVal SpecIn As String) As Boolean Dim Attr As Long ' Special cases: "C:", "..", "." all generate ' "Path not found" errors when passed to GetAttr. ' "D:\" may return an attribute value of 0 if ' it refers to a removeable drive. Select Case Len(SpecIn) Case 1 If SpecIn = "." Then IsDirectory = True Exit Function End If Case 2 If SpecIn = ".." Or InStr(SpecIn, ":") = 2 Then IsDirectory = True Exit Function End If Case 3 If InStr(SpecIn, ":\") = 2 Then IsDirectory = True Exit Function End If End Select ' Guard against bad SpecIn by ignoring errors. ' Get attribute of SpecIn. On Error Resume Next Attr = GetAttr(SpecIn) On Error GoTo 0 ' Check for presence of Directory attribute. If (Attr And vbDirectory) = vbDirectory Then IsDirectory = True End If End Function Later... Karl -- [Microsoft Basic: 1976-2001, RIP] - |
