如何测试网络文件夹是否在VB6上

How to test if network folder is up on VB6

我在 VB6 上有一个应用程序,在执行特定操作后,它会为用户提供一个填充了一些图像的表单。这些图像位于外部服务器上。有时这台服务器由于某些维护而关闭,这会导致我的应用程序出现一些问题(例如 Bad file error 52)。

我想知道是否有任何方法可以"test" 以更少的超时(如 2 秒)访问文件夹。如果服务器在 2 秒后没有响应,我将卸载图片表单,以便用户可以继续正常工作。

谢谢和最诚挚的问候

你应该可以做这样的事情

Dim fso As FileSystemObject
Dim exists as Boolean

Set fso = New FileSystemObject
exists = fso.FolderExists("\MyServer\SomeFolder\")

If Not exists Then
    'Let the user know the server is down
Else
    'Server is up so load your pictures
End If