在网上下载了一个CLSFTP的类,上传下载都没有问题,但是里面有个方法不知道该怎么用?
想实现的功能是:
进入FTP的目录,查询文件列表,如果文件名“20111118080024_***.***”比本地的最大文件名都大(字符对比),就下载;
然后定时刷新FTP目录循环下载,也可以对比文件的创建时间。下面这个方法是调用wininet.dll的FtpFindFirstFile(m_hSession&, _FullDir$ & Filter$, WFD, _INTERNET_FLAG_RELOAD Or _INTERNET_FLAG_NO_CACHE_WRITE, 0&)方法,我定义了
Dim GetFileNames$(), GetFileSizes&()
Dim a As New clsftp
然后调用
j = a.GetDirListing(GetFileNames$(), GetFileSizes&())
后面就不知道该怎么用了,使用UBOUND(GETFILENAMES())都会显示错误,大家帮忙看下~
------------------------------------------------
Public Function GetDirListing&(FileNames$(), FileSizes&(), Optional ByVal SubDir$ = vbNullString)
    On Local Error GoTo Handler    Dim WFD As WIN32_FIND_DATA
    Dim Filter$
    Dim hFind&, hFindConnect&
    Dim FileSize&
    Dim TempFileName$, TempFileSize&
    Dim FullDir$
    Dim i%    GetDirListing& = FAILURE&    Screen.MousePointer = vbHourglass    'Obtain the current FTP path
    Filter$ = "*.*"    FullDir$ = m_Dir$ & SubDir$    AddRemFwdSlash FullDir$, 1    'If not connected, raise an error
    If m_hSession& = NO_CONNECTION& Then
        Err.Raise ERR_NOT_CONNECTED_TO_SITE, "clsFTP:PutFile", ERR_NO_CONNECTION$
    End If    'Connection handles used by the FtpFindFirstFile
    'API go out of scope once the files are
    'listed, therefore it can not be reused.
    'This restriction is handled by obtaining
    'a fresh connection handle each time a call
    'to FtpFindFirstFile is required, and releasing
    'it once finished.
    hFindConnect& = GetInternetConnectHandle()    hFind& = FtpFindFirstFile(m_hSession&, _
            FullDir$ & Filter$, WFD, _
            INTERNET_FLAG_RELOAD Or _
            INTERNET_FLAG_NO_CACHE_WRITE, 0&)    If hFind& Then
        i% = 0
        Do
            ReDim Preserve FileNames$(i%)
            ReDim Preserve FileSizes&(i%)
            TempFileName$ = ClipNull(WFD.cFileName)
            If Len(TempFileName$) Then
                If WFD.dwFileAttributes And vbDirectory Then
                    TempFileName$ = TempFileName$ & FWDSLASH$
                    TempFileSize& = 0
                Else
                    TempFileSize& = WFD.nFileSizeLow
                End If
                FileNames$(i%) = TempFileName$
                FileSizes&(i%) = TempFileSize&
            End If
            'Continue while valid
            i% = i% + 1
        Loop While InternetFindNextFile(hFind&, WFD)    End If                                                 'If hFind&    InternetCloseHandle hFindConnect&
    InternetCloseHandle hFind&    Screen.MousePointer = vbDefault
    GetDirListing& = SUCCESS&ExitProc:
    Exit FunctionHandler:
    GetDirListing& = Err.Number
    Resume ExitProcEnd Function