Multiple File Upload (General questions)

by michael090 @, (7475 days ago)

I'm having problem with uploading multiple files is there's a way to queue file to be uploaded?

Dim filepath As IO.Directory
Dim filearray As Array
Dim filename As String
Dim filefolder As String
Dim i As Integer
'Sftp1.Blocking = False
filefolder = filepath.GetCurrentDirectory()
filearray = filepath.GetFiles(txtLocalPath.Text)
For i = 0 To filearray.Length - 1
filename = filearray(i)
If Sftp1.State.SendingFile.Executing Then
AddToList(vbCrLf & ***UPLOADING file & txtmsg.Text)
Sftp1.PutFile(filename, /home/test )
End If
upload(filename)
Next[:smile:][:smile:]

locked

Re: Multiple File Upload

by Jasmine, (7475 days ago) @ michael090

Can you make sure Sftp1.Blocking = True? Your code looks ok to me - assuming Blocking is set. Can you try that?

locked

Re: Multiple File Upload

by michael090 @, (7472 days ago) @ Jasmine

I already try to set SFTP1.Blocking=true but my program hangs...

locked

Re: Multiple File Upload

by Jasmine, (7472 days ago) @ michael090

Can you please make standalone sample that duplicates your problem, then zip it and send to techsupport@weonlydo.com ? I'd like to try it out - it cannot hang with no reason, and I need to see full code in order to give you more details.

Possible?

locked

Re: Multiple File Upload

by michael090 @, (7472 days ago) @ Jasmine

sure... wait for a minute.

locked

Re: Multiple File Upload

by michael090 @, (7472 days ago) @ michael090

Sir,
I'd already sent the zip file to your email.

Regards,
Dan

locked

Re: Multiple File Upload

by Jasmine, (7472 days ago) @ michael090

I looked at the source. Didn't try it yet but I think I see the problem. You are using Blocking *AND* events. You shouldn't be doing that. Let me explain.

Each command you call blocks. 'Connect' blocks. 'PutFile' blocks.

So, you call
1. Connect (your thread blocks),
2. we do something under the hood,
3. we fire 'Connected' event,
4. we unblock so you can proceeed.

now, imagine you call 'PutFile' between 3 and 4 - so you cause second blocking to occur - and app freezes.

In order to avoid this problem you should NOT execute blocking methods from within event code. So, you can
a) set Blocking = False and change your code a bit so it works in async manner (we call you when something is done)
b) move code from 'Connected' event to just after calling 'Connect' method.

Can you try that?

locked

Re: Multiple File Upload

by michael090 @, (7471 days ago) @ Jasmine

Sir,
I also find my problem why the program freeze when i try to upload multiple files. I tried to trigger the upload after the event of connected . That's why it always execute the upload function everything the Connected event was done....


Thanks for you big help...

Regards,
Dan

locked