Hi
I'm using FTP net pro to download a bunch of files. I have this working fine but I also need to delete these files once downloaded.
As the remote folders contents may change at any time, I can not simply delete all files in the folder. Rather I need to delete whats been downloaded.
My idea was to use the BeginDownloadMultiple method to kick it off.
I have a SecureFTPConnection1_Downloaded sub which contains a BeginDeleteFile command to queue a delete command for each file as its downloaded.
Then there is a SecureFTPConnection1_Deleted sub which tells me its deleted file x.
However this system is not working. Its says its deleted a file but in fact it hasn't. Also only deletes one file and not the lot.
Can this work or should I use the BeginDeleteMultiple method with a list of the downloaded files used as a FileFilter?
Could you advise the form,at of the FileFilter when its making up a list of file names please?
* part of 'onConnect' code
ftpConnection.BeginDownloadMultiple(exportFolder, "*.mpeg", New AsyncCallback(AddressOf OnDownload), ftpConnection)
*end code part
Private Sub OnDownload(ByVal ar As IAsyncResult)
Try
Dim c As SecureFTPConnection = CType(ar.AsyncState, SecureFTPConnection)
c.EndDownloadFile(ar)
AddToList("onDownload")
Catch ex As Exception
AddToList("Download error. Skipping file, it may now be missing.")
End Try
End Sub 'OnDownload
Private Sub SecureFTPConnection1_Downloaded(ByVal sender As Object, ByVal e As EnterpriseDT.Net.Ftp.FTPFileTransferEventArgs) Handles SecureFTPConnection1.Downloaded
AddToList("Successfully downloaded " & e.RemoteFile)
doLogEvent("Run", "Downloaded " & e.RemoteFile & " - size " & e.FileSize)
If bDelete Then
ftpConnection.BeginDeleteFile(e.RemoteFile, New AsyncCallback(AddressOf OnDelete), ftpConnection)
AddToList(" File " & e.RemoteFile & " marked for deletion from server.")
End If
End Sub
Private Sub SecureFTPConnection1_Deleted(ByVal sender As Object, ByVal e As EnterpriseDT.Net.Ftp.FTPFileTransferEventArgs) Handles SecureFTPConnection1.Deleted
AddToList("Successfully deleted " & e.RemoteFile)
doLogEvent("Run", "Deleted " & e.RemoteFile)
End Sub
Any help or thoughts much appreciated.
cheers
Malcom