Here's how you can subscribe to Ftp.Progress
event:
private void Ftp_Progress(object sender, ProgressEventArgs e)
{
this.BeginInvoke((MethodInvoker) (() =>
{
_progressBar.Value= (int) e.Percentage;
}));
}
private void btnUpload_Click(
object sender,
EventArgs e)
{
Thread thread = new Thread(() =>
{
try
{
using (Ftp ftp = new Ftp())
{
ftp.Progress += Ftp_Progress;
ftp.Connect("ftp.example.com");
ftp.Login("ftptest", "cypher");
ftp.Upload("d:\\file.txt", "report.txt");
// When there is no exception -
// Upload succeeded here.
ftp.Close();
}
}
catch (Exception ex)
{
Log(ex.ToString());
}
});
thread.Start();
}