Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
WebDAV .NET
>
Tutorial
> Abort upload
During asynchronous upload you can abort upload.
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.UploadProgress += new UploadProgressEventHandler(UploadProgress); FileUpload fileUpload = resource.UploadFile("http://myserver/dav/file1.dat", "c:\\file1.dat"); //Press ENTER to abort upload Console.Read(); fileUpload.Abort(); //Press ENTER to exit. Console.Read(); } private static void UploadProgress(object sender, ProgressEventArgs e) { Console.WriteLine(e.Progress); if (e.IsComplete) { Console.WriteLine("Upload 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.UploadProgress, AddressOf OnUploadProgress Dim fileUpload As FileUpload = resource.UploadFile("http://myserver/dav/file1.dat", "c:\\file1.dat") 'Press ENTER to abort upload Console.Read() fileUpload.Abort() 'Press ENTER to exit. Console.Read() End Sub Private Shared Sub OnUploadProgress(ByVal sender As Object, ByVal e As ProgressEventArgs) Console.WriteLine(e.Progress) If (e.IsComplete) Then Console.WriteLine("Upload completed") End If End Sub End Class End Namespace
Need help? Ask our developers:
Name*
Email*
Message*