Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
3k views
in .NET FTP by (1.5k points)
Hi

Using FTPpro in asynch mode in VB, I'm doing multiple file uploads using BeginUploadMultiple.
As the files are uploaded, I need to check the size of the uploaded files on a case by case basis before they are renamed on the server.

I would like to place the rename code inside the OnGetSize sub so that if size is ok we can then rename the file.
From the code below you'll see that I'm lost as to where I can obtain sRemoteFile.
Is there a way to pull the filename that has just had its size checked from the OnGetSize sub?

cheers
Malcom



Private Sub SecureFTPConnection1_Uploaded(ByVal sender As Object, ByVal e As EnterpriseDT.Net.Ftp.FTPFileTransferEventArgs) Handles SecureFTPConnection1.Uploaded
'check ul for non zero length file
ftpConnection.BeginGetSize(e.RemoteFile, New AsyncCallback(AddressOf OnGetSize), ftpConnection)
End sub

Private Sub OnGetSize(ByVal ar As IAsyncResult)
Try
Dim c As SecureFTPConnection = CType(ar.AsyncState, SecureFTPConnection)
Dim size As Long = c.EndGetSize(ar)
If size > 0 Then
'change the file extension
ftpConnection.BeginRenameFile(sRemoteFile, sRenamedFile, New AsyncCallback(AddressOf OnRename), ftpConnection)
Else
' go back and upload again
End If
Catch ex As Exception

End Try
End Sub 'OnGetSize

1 Answer

0 votes
by (162k points)
Why not pass in the filename as the last parameter (the state) rather than the ftpConnection? You probably have access to that anyway.

Categories

...