Results 1 to 7 of 7

Thread: Ftp Help Required App looks like its frozen

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    736

    Ftp Help Required App looks like its frozen

    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:
    1. Private Sub downloadFile_Click()
    2. Dim i As Long
    3.  
    4. On Error Resume Next
    5.            
    6.     For i = 0 To List2.ListCount - 1
    7.    
    8.             'Check if file has been selected
    9.         If List2.Selected(i) = True Then
    10.         Call FtpGetFile(hConnection, sFile.Text, App.Path & "\" & sFile.Text, 0, 0, 2, 0)
    11.         DoEvents
    12.         End If
    13.        
    14.    Next
    15. End Sub
    16.  
    17.  
    18. Sub DownloadFiles(ftp_url As String, username As String, password As String)
    19.    Dim sOrgPath  As String
    20.    
    21.    
    22.     'open an internet connection
    23.     hOpen = InternetOpen("API-Guide sample program", INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)
    24.     'connect to the FTP server
    25.     hConnection = InternetConnect(hOpen, ftp_url, INTERNET_DEFAULT_FTP_PORT, username, password, INTERNET_SERVICE_FTP, IIf(PassiveConnection, INTERNET_FLAG_PASSIVE, 0), 0)
    26.     sOrgPath = String(MAX_PATH, 0)  'create a buffer to store the original directory
    27.     FtpGetCurrentDirectory hConnection, sOrgPath, Len(sOrgPath) 'get the directory
    28.     FtpSetCurrentDirectory hConnection, "/jd/logs/"   'set the current directory to 'root/httpdocs'
    29.     EnumFiles hConnection   'enumerate the file list from the current directory ('root/testing')
    30.  
    31.  
    32.    
    33. End Sub
    34.  
    35.  
    36. Private Sub ftpconnect_Click()
    37. If ftpconnect.Caption = "Connect" Then
    38.     Screen.MousePointer = vbHourglass
    39.     DownloadFiles txtFTP, txtUserName, txtPassword
    40.     Screen.MousePointer = vbDefault
    41.     ftpconnect.Caption = "Disconnect"
    42.  
    43. Else
    44.  
    45. If ftpconnect.Caption = "Disconnect" Then
    46.     InternetCloseHandle hConnection
    47.     InternetCloseHandle hOpen
    48.     List2.Clear
    49.     ftpconnect.Caption = "Connect"
    50.     End If
    51. End If
    52.  
    53. End Sub

    thanks in advance

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    736

    Re: Ftp Help Required App looks like its frozen

    Hi guys also in looking at this code how could it be moded to resume a dl rather than dl complete file? thanks again

  3. #3
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Re: Ftp Help Required App looks like its frozen

    an Application Freeze usually happens when it encounters a line of code that takes much time for execution. There are various ways of getting rid of this. Try to check the codebank for some sources.
    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

  4. #4
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    Re: Ftp Help Required App looks like its frozen

    Correct! Besides there could be a timed out or probably the size is big for downloading. Have you tried downloading text files only?

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    736

    Re: Ftp Help Required App looks like its frozen

    Bump

  6. #6
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Ftp Help Required App looks like its frozen

    The Inet APIs (which I assume is what you're using) will appear to "freeze" your app when they're doing something, like downloading a file. I'm not aware of any way around this other than executing the functions in another thread.

    This is why I personally use the Winsock control instead. But that will add another dependency to your project.

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    736

    Re: Ftp Help Required App looks like its frozen

    Thanks digi rev for the reply i wish i could change to that now but i didnt write this codes as i am fairly new to vb and i dont think i could mod it to use winsock instead

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width