Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.visual.basic    |    MS Visual Basic discussions, NOT dot-net    |    10,840 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 10,795 of 10,840    |
|    Rico to All    |
|    Having an FTP code issue    |
|    02 Sep 09 16:08:03    |
      XPost: microsoft.public.access       From: me@you.com              Hi All,              I have an FTP routine in my A2K2 database that I am using to transfer files.       When I call the FtpFindFirstFile API, I get an error 12002 which is a       timeout error. I've removed the timeout from the FTP server, but I still       get this error. I read that the files can can only be enumerated once using       this function and if it's called again, it will produce an error. I think       this is what is happening, since when I close the database and re-open it, I       can run this function for the first time without issue.              My question is, how do I tell if the files / folders have been enumerated       once already and how can I reset this so I can enumerate again? This is the       function that is giving me problems;              Public Sub GetFileNames(Optional pRemoteDir, Optional pFileSpec)       'Fill the FileNames collection with list       'of files matching pFileSpec from server's       'current directory               Dim hFind As Long        Dim LastErr As Long        Dim fdata As WIN32_FIND_DATA        '        'Bail out if server connection not established        If m_hCon = 0 Then RaiseError errNotConnected        '        'Handle optional parameters        If Not IsMissing(pRemoteDir) Then m_RemoteDir = pRemoteDir        If Not IsMissing(pFileSpec) Then m_FileSpec = pFileSpec        '        'Handle empty properties        If Len(m_RemoteDir) = 0 Then m_RemoteDir = "."        If Len(m_FileSpec) = 0 Then m_FileSpec = "*.*"        '               ClearFileNames               'Change directory on server        Me.SetDir m_RemoteDir        '        'Find first file matching FileSpec        fdata.cFileName = String(MAX_PATH, 0)        'Obtain search handle if successful        'FtpSetCurrentDirectory m_hCon, "."               hFind = FtpFindFirstFile(m_hCon, m_FileSpec, fdata, 0, 0)        LastErr = Err.LastDllError        If hFind = 0 Then        'Bail out if reported error isn't end-of-file-list        If LastErr <> ERROR_NO_MORE_FILES Then        RaiseError errFindFirst        End If        'Must be no more files        Exit Sub        End If        '        'Reset variable for next call        LastErr = NO_ERROR        '        'Add filename to the collection        FileNames.Add Left(fdata.cFileName, _        InStr(1, fdata.cFileName, vbNullChar, vbBinaryCompare) - 1)        Do        'Find next file matching FileSpec        fdata.cFileName = String(MAX_PATH, 0)        If InternetFindNextFile(hFind, fdata) = False Then        LastErr = Err.LastDllError        If LastErr = ERROR_NO_MORE_FILES Then        'Bail out if no more files        Exit Do        Else        'Must be a 'real' error        InternetCloseHandle hFind        RaiseError errFindNext        End If        Else        'Add filename to the collection        FileNames.Add Left(fdata.cFileName, _        InStr(1, fdata.cFileName, vbNullChar, vbBinaryCompare) - 1)        End If        Loop        '        'Release the search handle        InternetCloseHandle hFind              End Sub              Thanks!       Rick              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca