Chilkat HOME Android™ ASP Visual Basic VB.NET C# iOS (IPhone) Objective-C C++ C Unicode C++ Unicode C MFC Delphi DLL Delphi ActiveX FoxPro Java Perl PHP Extension PHP ActiveX Python PowerShell Ruby SQL Server VBScript
FTP Download with Progress MonitoringDownload: Chilkat .NET Assemblies Demonstrates how to download a file from an FTP server with progress monitoring event callbacks. Also demonstrates how to abort an FTP download while in progress. // Progress monitor callback -- called each time the percentage completion
// updates to a larger value.
public void OnFtpPercentDone(object source, Chilkat.FtpPercentDoneEventArgs args)
{
// args.PercentDone is an integer value between 1 and 100.
progressBar1.Value = args.PercentDone;
// args.Abort can be set to True to abort the FTP trabsfer while in progress.
// This example aborts the FTP transfer after it is 60% complete.
if (args.PercentDone >= 60)
{
args.Abort = true;
}
}
// FTP Get with progress monitoring
// Demonstrates how to download a file from an FTP server with percentage completion event callbacks.
private void button6_Click(object sender, System.EventArgs e)
{
Chilkat.Ftp2 ftp = new Chilkat.Ftp2();
ftp.UnlockComponent("Any string works for 30-day trial");
ftp.Hostname = "ftp.chilkatsoft.com";
ftp.Username = "****";
ftp.Password = "****";
ftp.EnableEvents = true;
// Some FTP server may require that the AutoGetSizeForProgress property be set to true.
// Only do this if you see that percent-done progress events are not firing.
ftp.AutoGetSizeForProgress = true;
ftp.OnFtpPercentDone += new Ftp2.FtpPercentDoneEventHandler(OnFtpPercentDone);
// Connect and login.
bool success = ftp.Connect();
if (success)
{
// Download a file
success = ftp.GetFile("ChilkatZipSE.exe","ChilkatZipSE.exe");
if (success)
{
MessageBox.Show("Done!");
}
else
{
MessageBox.Show(ftp.LastErrorText);
}
}
else
{
MessageBox.Show(ftp.LastErrorText);
}
}
|
© 2000-2013 Chilkat Software, Inc. All Rights Reserved.