tags:

views:

1461

answers:

6

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?

+5  A: 

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.

Mike L
+1  A: 

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
Darrel Miller
+1  A: 

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.

Daren Thomas
A: 

What sort of file I/O are you doing? If it's text, look into using a FileSystemObject.

Matthew Cole
+1  A: 

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
dummy
A: 

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.

sharvell