Visual Basic 6 和 UNC 路径
我收到开发人员的反馈,“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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
我们有一个旧版 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.
即使是老式的文件处理类型也可以工作:
Even the old school type of file handling does work:
这是一种有效的方法。
Here is one way that works.
在 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
如果您使用的是 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.
您正在执行什么类型的文件 I/O? 如果是文本,请考虑使用 FileSystemObject。
What sort of file I/O are you doing? If it's text, look into using a FileSystemObject.
当存在以下项目的组合时,我观察到 VB6 UNC 路径问题:
通常是 75 路径文件访问错误或 54。有时这可能与 API 有关,例如上述 UNC 上的 getshortfilename 和 getshortpathname。
除此之外,它们工作得很好......映射路径通常不会有这些问题,但那些该死的驱动器映射经常断开连接,并且可以随时更改,从而导致许多支持问题。
I have observed VB6 UNC path issues when a combination of the items below exist:
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.