This example is written in VB.NET with Visual Studio 2008, using DotNET Framework 3.5. It's built on a "Windows Forms Application" with a single Form (Form1) and the Reference to the EnterpriseDT namespace DLL is added explicitly. I'm using EnterpriseDT NET Free version.
You don't really need all the Imports here, but if you start customizing other controls in the namespace it's nice to have the whole thing laid out right from the start.
Imports EnterpriseDT
Imports EnterpriseDT.Net
Imports EnterpriseDT.Util.Debug
Imports EnterpriseDT.Net.Ftp
Public Class Custom_FTPConnection_Class
Inherits FTPConnection
Private TimeInTransfer As TimeSpan
Private TransferTimer As DateTime
Private TransferAmount As Integer = 0
Private Sub Uploading_EventHandler() Handles Me.Uploading
TransferTimer = Date.Now
TransferAmount = 0
End Sub
Private Sub BytesTransferred_EventHandler() Handles Me.BytesTransferred
TransferAmount = TransferAmount + TransferBufferSize
TimeInTransfer = Date.Now.Subtract(TransferTimer)
MsgBox(TransferAmount & " bytes transferred in " & TimeInTransfer.Milliseconds & " milliseconds at a calculated speed of " & TransferAmount / TimeInTransfer.Milliseconds & " bpms.")
End Sub
End Class
The above is your custom class with event handling for BytesTransferred. It demonstrates how to track bytes uploaded using the BytesTransferred Event and the TransferBufferSize, and the simple maths involved in calculating the transfer speed based on that data.
Below is the code for the Form itself.
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim CustomFTPThread As New System.Threading.Thread(AddressOf Threaded_CustomFTP)
CustomFTPThread.Start()
End Sub
Private Sub Threaded_CustomFTP()
Dim MyFTPDemo As New Custom_FTPConnection_Class
MyFTPDemo.ServerAddress = 'You need to supply your own ServerAddress String
MyFTPDemo.ServerPort = 'You need to supply your own Port Integer
MyFTPDemo.UserName = 'You need to supply your own UserName String
MyFTPDemo.Password = 'You need to supply your own Password String
MyFTPDemo.Connect()
Dim strOutput As System.IO.StreamWriter = My.Computer.FileSystem.OpenTextFileWriter("C:\Test.txt", 0)
strOutput.Write("HELLO WORLD!")
strOutput.Close()
MyFTPDemo.UploadFile("C:\Test.txt", "Test.txt")
MyFTPDemo.Dispose()
End Sub
End Class
What actually happens in this Form Code is that when you first start the Application, it creates and fires a separate thread. The separate thread first creates a new object of our custom Class (the EnterpriseDT inherited FTPConnection with Bytes Transferred event handling), then connects, creates a new Text File on your C:\ drive, and then uploads that file to the connected FTP Server.
Make sure you replace my comments in the above code with valid FTP Server data before you run the demo.
Hope this helps.