I'm receiving feedback from a developer that "The only way visual basic (6) can deal with a UNC path is to map it to a drive." Is this accurate? And, if so, what's the underlying issue and are there any alternatives other than a mapped drive?
We have a legacy VB6 app that uses UNC to build a connection string, so I know VB6 can do it. Often, you'll find permissions problems to be the culprit.
Here is one way that works.
Sub Main()
Dim fs As New FileSystemObject ' Add Reference to Microsoft Scripting Runtime
MsgBox fs.FileExists("\\server\folder\file.ext")
End Sub
I don't think this is True, if you are using the Scripting.Runtime
library.
Oldschool VB had some language constructs for file handling. These are evil. Don't use them.
What sort of file I/O are you doing? If it's text, look into using a FileSystemObject.
Even the old school type of file handling does work:
Open "\\host\share\file.txt" For Input As #1
Dim sTmp
Line Input #1, sTmp
MsgBox sTmp
Close #1
I have observed VB6 UNC path issues when a combination of the items below exist:
- the unc points to a hidden '$' share
- the server name exceeds 8 chars and or has non standard chars
- a portion of the path is exceptionally long
- the server has 8.3 support turned of for performance purposes
Usually a 75 path file access error or 54. At times this may be related to API's such as getshortfilename and getshortpathname on the aforementioned UNC's.
Other than that they work great... A mapped path will usually not have these issues but those darned drive mappings disconnect often and can change at anytime causing many support headaches.