Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi there, im having some serious trouble trying to get my program to download from an ftp site- it makes my app hang during the download and only sometimes it pulls through after the download is complete- any suggestions...Please...the code is right coz i get the file all the time, but it makes my program hang. Thanks Anthony

Seeing the code would really help if you want any help in solving the problem.
Just saying it doesn't work is as useful as sunglasses on a rainy day.
What are you using, APIs or the VB Active X control? Are you checking for feed back from the server.
Don't forget that when you send the request to the server, the server has to respond. If the server is busy, there will be a delay in that response. What is you application doing while it is waiting for this response?
Stuart

Ok here is the code, i dont know what this uses, it`s a dll called FTP_VB6, that is what i`m using. now i can connect get the file size and change dir no problem but when i start the download it hangs untill it`s finished, sometimes it stays frozen but i can still complete the download. Any help would be awsome!! thanks Ant
strFtpAddress = "ftp.blablabla.co.za"
intServerPort = 21
strUserName = "yousgsdgse"
strPassword = "passletter"
Label13.Visible = True
ConnectSuccess =MyFtp.Connect(strFtpAddress, intServerPort, strUserName, strPassword)
If ConnectSuccess = True Then
Label17.Visible = True
Label17.Caption = "Connection Made"
End If
If ConnectSuccess = False Then
Label17.Visible = True
Label17.Caption = "Connection Failed"
Exit Sub
End If
strDirectoryName = "/httpdocs/PowerCar"
SetCurDir = MyFtp.SetCurrentDirectory(strDirectoryName)
Label14.Visible = True
If SetCurDir = True Then
Label18.Visible = True
Label18.Caption = "Success"
End If
If SetCurDir = False Then
Label18.Visible = True
Label18.Caption = "Failure"
Exit Sub
End If
FileAnalize = MyFtp.GetFileSize("Power Car Consultant.mdb", Filesize)
Label15.Visible = True
If FileAnalize = True Then
Label19.Visible = True
Label19.Caption = Filesize & " Bytes"
End If
If FileAnalize = False Then
Label19.Visible = True
Label19.Caption = "Failure"
Exit Sub
End IfDelSAV.DeleteFile App.Path & "\New\Power Car Consultant.mdb"
Label16.Visible = True
Label20.Visible = True
Label20.Caption = "Getting File"
lngFileTransferType= FTP_TRANSFER_TYPE_BINARY
blnOverwrite = True
DownLoad = MyFtp.DownloadFile("Power Car Consultant.mdb", App.Path & "\New\Power Car Consultant.mdb", lngFileTransferType, blnOverwrite, , Return_ErrorDesc)
Label20.Caption = "Download Complete"
MyFtp.Disconnect

I am not familiar with that DLL so you are very much on your own there.
If you were using the API or the standard VB Active X I might have been able to help you.
However, all the problems appear to be in the last line. You send the file request, then you are stuck in the DLL until it has finises. If there is any delay at the FTP sever then your app appears to be hung until it returns from the FTP.Download call. That is unavoidable when using a DLL in synchronous mode.
Check the DLLs documentation and see if it has a callback function. This should allow you to monitor the progress of the download and see where the delay is occurring in what is know as asynchronously mode.
Stuart

Thanks for your help, i have another question though, if you dont mind, this code doesnt work and i have no idea why?, Thanks anthony.
With Inet1
.Protocol = icFTP
.RemoteHost = "ftp.pdfheredttttion.co.za"
.UserName = "pdffdkftionco"
.Password = "fdfkyrtyfs6"
.URL="ftp.pdfheredttttion.co.za/httpdocs/PowerCar/".Execute .URL, "Get " & "Test.txt" & " " & App.Path & "\New\Test.txt"
Do While .StillExecuting
DoEvents
Loop
End With

There is something wrong in the last line where you define the URL. You define the URL separately and the doc name is defined in the get statement. The Doc names should include the full path name relative to the current folder on the FTP server.
.URL="ftp.pdfheredttttion.co.za"
Inet1.Execute URL,"GET httpdocs/PowerCar/Test.txt" & App.Path & "\New\Test.txt"
Everything including and after the GET is a single string. You would be better building the string first to make sure you are getting what you intended.
Try downloading this Example from Microsoft. This demonstrates to to use the API for FTP access. It is a lot faster and more efficient.Stuart

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |