Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
FTP Upload with Progress Monitoring
Demonstrates how to upload a file to an FTP server with progress monitoring event callbacks. Also demonstrates how to abort an FTP upload 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 while in progress.
// This example aborts the FTP transfer after it is 50% complete.
if (args.PercentDone >= 50)
{
args.Abort = true;
}
}
// FTP Put with progress monitoring event callbacks.
// Upload a file to an FTP server with percent done callbacks.
private void button5_Click(object sender, System.EventArgs e)
{
Chilkat.Ftp2 ftp = new Chilkat.Ftp2();
ftp.UnlockComponent("Any string unlocks for 30-day trial.");
ftp.Hostname = "ftp.chilkatsoft.com";
ftp.Username = "***";
ftp.Password = "***";
ftp.EnableEvents = true;
// Set the SendBufferSize to a smaller value than the default of 512K to get more frequent callbacks:
// This may slightly degrade performance.
ftp.SendBufferSize = 4096;
ftp.OnFtpPercentDone += new Ftp2.FtpPercentDoneEventHandler(OnFtpPercentDone);
bool success = ftp.Connect();
if (success)
{
success = ftp.PutFile("uploadTest.txt","uploadTest.txt");
if (success)
{
MessageBox.Show("Done!");
}
else
{
MessageBox.Show(ftp.LastErrorText);
}
}
else
{
MessageBox.Show(ftp.LastErrorText);
}
}
|
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.