我在FORM LOAD时,
File1.Pattern = "62*.*"
File1.Path = "\\22.140.192.11\file"
但会出现“路径找不到”如果预先在网上邻居中访问一下这个路径,程序可以通过,我想是不曾访问网上邻居而运行程序时,网络超时问题,请问如何解决阿???我用Filelistbox的目的是读取"\\22.140.192.11\file"的所有62*.*的文件名,有其他方法实现吗??

解决方案 »

  1.   

    Public Type NETRESOURCE
        dwScope As Long
        dwType As Long
        dwDisplayType As Long
        dwUsage As Long
        pLocalName As String
        pRemoteName As String
        pComment As String
        pProvider As String
    End Type
    Public Const RESOURCETYPE_DISK = &H1
    Public Declare Function WNetAddConnection2 Lib "mpr.dll" Alias "WNetAddConnection2A" (lpNetResource As NETRESOURCE, ByVal lpPassword As String, ByVal lpUserName As String, ByVal dwFlags As Long) As LongPublic Function ConnectServer(ServerAddr As String, UserName As String, Password As String) As Boolean
        Dim ConnInfo As NETRESOURCE
        ConnInfo.pLocalName = vbNullString
        ConnInfo.dwType = RESOURCETYPE_DISK
        ConnInfo.pRemoteName = ServerAddr
        If WNetAddConnection2(ConnInfo, Password, UserName, 0) = 0 Then
            ConnectServer = True
        Else
            ConnectServer = False
        End If
    End Function