Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
WebDAV .NET
>
Tutorial
> Abort download
During asynchronous download you can abort download.
C# example
using System; using System.Net; using Independentsoft.Webdav; namespace Sample { class Program { static void Main(string[] args) { NetworkCredential credential = new NetworkCredential("username", "password"); WebdavSession session = new WebdavSession(credential); Resource resource = new Resource(session); resource.DownloadProgress += new DownloadProgressEventHandler(DownloadProgress); FileDownload fileDownload = resource.DownloadFile("http://myserver/dav/file1.dat", "c:\\file1.dat"); //Press ENTER to abort download Console.Read(); fileDownload.Abort(); //Press ENTER to exit. Console.Read(); } private static void DownloadProgress(object sender, ProgressEventArgs e) { Console.WriteLine(e.Progress); if (e.IsComplete) { Console.WriteLine("Download completed"); } } } }
VB example
Imports System Imports System.IO Imports System.Net Imports Independentsoft.Webdav Namespace Sample Class Module1 Shared Sub Main(ByVal args() As String) Dim credential As NetworkCredential = New NetworkCredential("username", "password") Dim session As WebdavSession = New WebdavSession(credential) Dim resource As Resource = New Resource(session) AddHandler resource.DownloadProgress, AddressOf OnDownloadProgress Dim file As FileDownload = resource.DownloadFile("http://myserver/dav/file1.dat", "c:\\file1.dat") 'Press ENTER to abort download Console.Read() file.Abort() 'Press ENTER to exit. Console.Read() End Sub Private Shared Sub OnDownloadProgress(ByVal sender As Object, ByVal e As ProgressEventArgs) Console.WriteLine(e.Progress) If (e.IsComplete) Then Console.WriteLine("Download completed") End If End Sub End Class End Namespace
Need help? Ask our developers:
Name*
Email*
Message*