Hi guys i got the following code for ftp download problem i have is its like the app is frozen for the duration of the download i checked in task manager and pc also thinks its not repsponding this corrects when download finishes. its usually for a second or so on 3 mb files but the bigger the file the longer the freeze pc still works fine all the time this is happening its the app that is non reponsive. i dont understand this code as well as i could and i cant seem to fix it. any help would be great
VB Code:
Private Sub downloadFile_Click() Dim i As Long On Error Resume Next For i = 0 To List2.ListCount - 1 'Check if file has been selected If List2.Selected(i) = True Then Call FtpGetFile(hConnection, sFile.Text, App.Path & "\" & sFile.Text, 0, 0, 2, 0) DoEvents End If Next End Sub Sub DownloadFiles(ftp_url As String, username As String, password As String) Dim sOrgPath As String 'open an internet connection hOpen = InternetOpen("API-Guide sample program", INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0) 'connect to the FTP server hConnection = InternetConnect(hOpen, ftp_url, INTERNET_DEFAULT_FTP_PORT, username, password, INTERNET_SERVICE_FTP, IIf(PassiveConnection, INTERNET_FLAG_PASSIVE, 0), 0) sOrgPath = String(MAX_PATH, 0) 'create a buffer to store the original directory FtpGetCurrentDirectory hConnection, sOrgPath, Len(sOrgPath) 'get the directory FtpSetCurrentDirectory hConnection, "/jd/logs/" 'set the current directory to 'root/httpdocs' EnumFiles hConnection 'enumerate the file list from the current directory ('root/testing') End Sub Private Sub ftpconnect_Click() If ftpconnect.Caption = "Connect" Then Screen.MousePointer = vbHourglass DownloadFiles txtFTP, txtUserName, txtPassword Screen.MousePointer = vbDefault ftpconnect.Caption = "Disconnect" Else If ftpconnect.Caption = "Disconnect" Then InternetCloseHandle hConnection InternetCloseHandle hOpen List2.Clear ftpconnect.Caption = "Connect" End If End If End Sub
thanks in advance




Reply With Quote