Visual Basic 6 和 UNC 路径

发布于 2024-07-04 23:48:03 字数 101 浏览 5 评论 0原文

我收到开发人员的反馈,“Visual Basic (6) 处理 UNC 路径的唯一方法是将其映射到驱动器。” 这准确吗? 如果是这样,根本问题是什么?除了映射驱动器之外还有其他选择吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

小耗子 2024-07-11 23:48:03

我们有一个旧版 VB6 应用程序,它使用 UNC 构建连接字符串,所以我知道 VB6 可以做到这一点。 通常,您会发现权限问题是罪魁祸首。

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.

卖梦商人 2024-07-11 23:48:03

即使是老式的文件处理类型也可以工作:

Open "\\host\share\file.txt" For Input As #1
Dim sTmp
Line Input #1, sTmp
MsgBox sTmp
Close #1

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
躲猫猫 2024-07-11 23:48:03

这是一种有效的方法。

Sub Main()

    Dim fs As New FileSystemObject ' Add Reference to Microsoft Scripting Runtime
    MsgBox fs.FileExists("\\server\folder\file.ext")

End Sub

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
飞烟轻若梦 2024-07-11 23:48:03

在 VB6 中,您不能将 CHDrive 用于 UNC 路径。

由于 App.Path 返回 UNC 路径,因此尝试使用 ChDrive 到此路径,ChDrive App.Path 将导致错误。

正如 Microsoft 所说“ChDrive 无法处理 UNC 路径,因此当 App.Path 返回一个时会引发错误”。 有关详细信息,请参阅 http://msdn。 microsoft.com/en-us/library/aa263345(v=vs.60).aspx

In VB6 you cannot use CHDrive to a UNC path.

Since App.Path returns a UNC path, attempting to use ChDrive to this path, ChDrive App.Path will cause an error.

As Microsoft say "ChDrive cannot handle UNC paths, and thus raises an error when App.Path returns one". For more information, look at http://msdn.microsoft.com/en-us/library/aa263345(v=vs.60).aspx

用心笑 2024-07-11 23:48:03

如果您使用的是 Scripting.Runtime 库,我认为这不是真的。

Oldschool VB 有一些用于文件处理的语言结构。 这些都是邪恶的。 不要使用它们。

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.

渔村楼浪 2024-07-11 23:48:03

您正在执行什么类型的文件 I/O? 如果是文本,请考虑使用 FileSystemObject。

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

总攻大人 2024-07-11 23:48:03

当存在以下项目的组合时,我观察到 VB6 UNC 路径问题:

  • unc 指向隐藏的“$”共享
  • 服务器名称超过 8 个字符并且/或具有非标准字符
  • 路径的一部分非常长
  • 服务器有 8.3出于性能目的而关闭支持

通常是 75 路径文件访问错误或 54。有时这可能与 API 有关,例如上述 UNC 上的 getshortfilename 和 getshortpathname。

除此之外,它们工作得很好......映射路径通常不会有这些问题,但那些该死的驱动器映射经常断开连接,并且可以随时更改,从而导致许多支持问题。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文