Hello,
I just tried the new methods and have faced the following issue. I handled the SynchronizingFile event to track individual file that are being synchronized and their associated actions. To do that I am handling the SynchronizingFile event. The problem is that when looking at the event arguments I have e.RemoteFile.Name and e.LocalFile.Name. How can I reference the file that is being synchronized rather than the file according to its location. The error I am getting is NullReferenceException: "Object reference not set to an instance of an object."
It happens when I attempt to reference e.LocalFile.Name while it exists on the Remote path.
and also
when I attempt to reference e.RemoteFile.Name while it exists on the local path.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim conn As New EnterpriseDT.Net.Ftp.ExFTPConnection
conn.UserName = "user"
conn.Password = "pass"
conn.ServerAddress = "1.1.0.4"
conn.Connect()
conn.ChangeWorkingDirectory("/files/")
Dim Rules As FTPSyncRules = New FTPSyncRules
Rules.Direction = TransferDirection.UPLOAD
Rules.TransferNewOnly = True
Rules.IgnoreDate = True
Rules.FileNameFilter = "*.*"
AddHandler conn.SynchronizingFile, AddressOf SyncingFile
AddHandler conn.Synchronizing, AddressOf Syncing
AddHandler conn.Synchronized, AddressOf SyncDone
conn.Synchronize(Rules, "e:\myfiles", conn.ServerDirectory)
End Sub
Private Sub SyncDone(ByVal sender As System.Object, ByVal e As EnterpriseDT.Net.Ftp.FTPSyncEventArgs)
Dim conn As ExFTPConnection = DirectCast(sender, ExFTPConnection)
conn.Close()
End Sub
Private Sub SyncingFile(ByVal sender As System.Object, ByVal e As EnterpriseDT.Net.Ftp.FTPSyncFileEventArgs)
Console.WriteLine("{0} sync action is {1}", e.LocalFile.Name, e.Action.ToString)
End Sub
I also noticed that the LocalDirectory and RemoteDirectory .size property always returns 0.
This is all what I have write now. Please advise.
Thanks