.NET Core C#
.NET Core C#
HTTP Download with Progress Event Callbacks
See more HTTP Examples
Downloads a file via HTTP or HTTPS and uses event callbacks to monitor progress.Chilkat .NET Core C# Downloads
// AbortCheck callback method.
public void handleAbortCheck(out bool abort)
{
// Application code goes here.
}
// PercentDone callback method.
public void handlePercentDone(int pctDone, out bool abort)
{
// Application code goes here.
}
// ProgressInfo callback method.
public void handleProgressInfo(string name, string value)
{
// Application code goes here.
}
private void ChilkatExample()
{
bool success = false;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Chilkat.Http http = new Chilkat.Http();
Chilkat.Http.AbortCheck abortCheck = new Chilkat.Http.AbortCheck(handleAbortCheck);
http.setAbortCheckCb(abortCheck);
Chilkat.Http.PercentDone percentDone = new Chilkat.Http.PercentDone(handlePercentDone);
http.setPercentDoneCb(percentDone);
Chilkat.Http.ProgressInfo progressInfo = new Chilkat.Http.ProgressInfo(handleProgressInfo);
http.setProgressInfoCb(progressInfo);
// Set a heartbeat in milliseconds
http.HeartbeatMs = 200;
// Download a file...
string localFilePath = "qa_output/Python-3.4.4.tar.xz";
success = http.Download("https://www.python.org/ftp/python/3.4.4/Python-3.4.4.tar.xz",localFilePath);
if (success == false) {
Debug.WriteLine(http.LastErrorText);
return;
}
Debug.WriteLine("OK!");
}