Hi,
I've made a program using the INET control to login to a ftp host, change to a specific directory, download any files that are located in this directory, and then delete these files.
The funny thing is, this works great when there are files in this directory and does everything that it is supposed to do, however, if the directory is empty, my program waits for about a minute before figuring out that there are no files. I can't seem to figure out what is causing this problem at all.
This is the routine which retrieves the contents of the ftp directory. It is the routine which hangs for almost a minute every time there is no files in the directory.
VB Code:
Public Function FTPGetDirectoryList() As Boolean 'Refreshed the remote directory listing On Error GoTo FTPGetDirectoryListError Do Until inetReady(False) DoEvents Loop FTPGetDirectoryList = True Call SendCommand("DIR") Exit Function FTPGetDirectoryListError: FTPGetDirectoryList = False MsgBox Err.Source & " " & Err.Number & " " & Err.Description End Function
And this is where the incoming file names are retrieved. For clarity sake, I took out all the code for the other 'states', which only display a message in the form title bar.
VB Code:
Private Sub Inet1_StateChanged(ByVal State As Integer) With frmOOCModule Dim Data1 As String, Data2 As String Select Case State Case icResponseCompleted .Caption = "Request completed, all data received" 'Loop until you get all chunks Do While True 'Change datatype to icByteArray to receive data in binary Data1 = Inet1.GetChunk(512, icString) 'MsgBox "Data: " & Data1 If Len(Data1) = 0 Then Exit Do DoEvents 'Transfer control to operating system Data2 = Data2 & Data1 Loop 'MsgBox "Data2: " & Data2 If Len(Data2) > 0 Then 'Keep track of the file names received, as well as the file count Erase strFTPFiles strFTPFiles = Split(Data2, vbCrLf) numFTPFiles = UBound(strFTPFiles) + 1 'Dim i As Integer 'For i = 1 To numFTPFiles ' MsgBox "File Name: " & strFTPFiles(i) 'Next i End If Case Else .Caption = "Unknown Error!" End Select If frmOptions.Inet1.StillExecuting Then .Caption = .Caption & ". Please wait..." End With End Sub
Does anyone have any clue why this freezes when there are no files? I must be blind because I can't figure it out!!!
Thanks for any help!
