Inet FTP wait on Download File

Hi.
I have created the FTP program and having a problem with it.

I have command button that executes downloading a file (text file) from FTP site, and run Module to convert this text file to .csv file.

I'm having a problem when I'm running this program.
Sometime the error say "permission denied" or " File not found".

I assume this error occur because the module start running before the file download complete.

I insert the code to wait 2 secounds before going to call this module.
But sometime it works, and sometimes it doesn't due to file size.

File size is always different, and network speed could differ each day.

How Can I make the program to wait until it complete downloading before it execute next line?

I'll really appreciate your help.
[844 byte] By [symyf] at [2007-11-20 11:07:17]
# 1 Re: Inet FTP wait on Download File
What control are you using? There's the Inet1.StillExecuting flag that helps
dglienna at 2007-11-9 19:33:55 >
# 2 Re: Inet FTP wait on Download File
Hi, Thank you for the reply.

I'm using INET control.

I have this Loop as many place as I could think of.
Do
DoEvents
Loop While Inet1.StillExecuting

But it still excecute next line before it complete downloading.
So I have inserted the code to Pause for 3 seconds.
I got this idea from another post.

But sometimes, it takes longer than 3 secounds to finish downloading the file.
SO in that case, it gives me error "File Not Found".
I want the program to wait to complete download and save the file onto local machine.

Any way to do this?

Thank you for your help.

Public Sub GetAllFiles()

Dim LocalFileName As String, cmd As String
Dim fName As String
Dim J As Integer
Dim sizeofArray As Integer

J = 1
sizeofArray = UBound(strSplit)

On Error GoTo GetRemoteFileErr

Do While (J < (sizeofArray - 1))

fName = getRemoteFileName(strSplit(J))

If Not (fName = "") Then

LocalFileName = "C:\FTP\" & fName
cmd = "GET " & fName & " " & LocalFileName


Do
DoEvents
Loop While Inet1.StillExecuting

If inetReady(True) Then
Call SendCommand(cmd)

Do
DoEvents
Loop While Inet1.StillExecuting



'----- Pause ----
Dim PauseTime, Start, Finish, TotalTime

PauseTime = 3 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop
'------------

MoveFile (fName)
End If


Do
DoEvents
Loop While Inet1.StillExecuting

End If

J = J + 1

Loop

MsgBox "Transfer Complete"
txtRemoteFileName.Text = ""
List1.Clear
Call SendCommand("DIR")

Exit Sub

GetRemoteFileErr:
MsgBox "Error: " & Err.Description
Resume Next

End Sub
symyf at 2007-11-9 19:34:50 >