login about faq

Hi I'm trying to Upload files with Asynchronous FTP Upload it works well with Console Project vb.net

when i'm try to make the same code in a web aspx project it work but very slow and when i check the filezilla server i find the server blok in the reading files but when i kick the user the file complete the upload with success please any one has Idea :(

and this is my function:

    Public Sub FTpUpload(ByVal localname As String, ByVal remot As String, ByVal host As String, ByVal login As String, ByVal password As String)
        Dim ftp As New Chilkat.Ftp2()

        Dim success As Boolean

        '  Any string unlocks the component for the 1st 30-days.
        success = ftp.UnlockComponent("Anything for 30-day trial")
        If (success <> True) Then
            System.Diagnostics.Debug.WriteLine("tp.LastErrorText & vbCrLf1:" & ftp.LastErrorText & vbCrLf)
            Exit Sub
        End If

        ftp.Hostname = host
        ftp.Username = login
        ftp.Password = password

        '  Connect and login to the FTP server.

        ftp.Passive = True
        success = ftp.Connect()

        If (success <> True) Then
            System.Diagnostics.Debug.WriteLine("tp.LastErrorText & vbCrLf2:" & ftp.LastErrorText & vbCrLf)

            Exit Sub
        End If

        '  Change to the remote directory where the file will be uploaded.
        'success = ftp.ChangeRemoteDir("test")
        'If (success <> True) Then
        '    Console.WriteLine("tp.LastErrorText & vbCrLf3:" & ftp.LastErrorText & vbCrLf)

        '    Exit Sub
        'End If

        Dim localFilename As String
        localFilename = localname
        Dim remoteFilename As String
        remoteFilename = remot

        '  Begin the upload in a background thread.
        '  Only 1 background upload or download may be active at any time.
        '  (per instance of an FTP object)
        '  To append to an existing file in the background, call
        '  AsyncAppendFileStart instead.
        success = ftp.AsyncPutFileStart(localFilename, remoteFilename)
        If (success <> True) Then
            System.Diagnostics.Debug.WriteLine("tp.LastErrorText & vbCrLf:" & ftp.LastErrorText & vbCrLf)

            Exit Sub
        End If

        'The application is now free to do anything else
        'while the file is uploading.
        'For this example, we'll simply sleep and periodically
        'check to see if the transfer if finished.  While checking
        '      however, we 'll report on the progress in both number
        '  of bytes tranferred and performance in bytes/second.
        'While ftp.AsyncFinished <> True
        '    System.Diagnostics.Debug.WriteLine(ftp.AsyncBytesSent & " bytes sent" & vbCrLf)
        '    System.Diagnostics.Debug.WriteLine(" bytes per second" & vbCrLf)

        '    '  Sleep 1 second.
        '    ftp.SleepMs(1000)
        'End While

        '  Did the upload succeed?
        If (ftp.AsyncSuccess = True) Then
            System.Diagnostics.Debug.WriteLine("File Uploaded!" & vbCrLf)

            '  The error information for asynchronous ops
            '  is in AsyncLog as opposed to LastErrorText
            System.Diagnostics.Debug.WriteLine("ftp.AsyncLog & vbCrLf" & ftp.AsyncLog & vbCrLf)

        End If



asked Apr 18 '14 at 04:02

totti's gravatar image


edited Apr 18 '14 at 07:27

The code snippet you posted doesn't quite make sense for this reason: The call to ftp.AsyncPutFileStart starts a background thread to begin doing the FTP upload. The main thread of execution then continues and tries to call ftpDisconnect immediately, which makes no sense because the background thread that is doing the upload is surely not yet completed. In fact, you cannot initiate another FTP operation (where a command is sent to the FTP server) until the background upload is completed.


answered Jun 20 '14 at 12:29

chilkat's gravatar image

chilkat ♦♦

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Apr 18 '14 at 04:02

Seen: 3,452 times

Last updated: Jun 20 '14 at 12:29

powered by OSQA