Independentsoft.Webdav
2.0.0
dotnet add package Independentsoft.Webdav --version 2.0.0
NuGet\Install-Package Independentsoft.Webdav -Version 2.0.0
<PackageReference Include="Independentsoft.Webdav" Version="2.0.0" />
<PackageVersion Include="Independentsoft.Webdav" Version="2.0.0" />
<PackageReference Include="Independentsoft.Webdav" />
paket add Independentsoft.Webdav --version 2.0.0
#r "nuget: Independentsoft.Webdav, 2.0.0"
#:package Independentsoft.Webdav@2.0.0
#addin nuget:?package=Independentsoft.Webdav&version=2.0.0
#tool nuget:?package=Independentsoft.Webdav&version=2.0.0
WebDAV .NET 2.0
WebDAV .NET is a WebDAV client library for .NET. It is built on HttpClient, every request method is asynchronous,
and it supports RFC 4918 and the WebDAV extensions in common use: access control, quota, collection
synchronization, search, versioning, bindings and more.
using System.Net;
using Independentsoft.Webdav;
using var client = new WebdavClient(new NetworkCredential("username", "password"))
{
BaseAddress = new Uri("https://myserver/dav/")
};
foreach (ResourceInfo resource in await client.List("documents/"))
{
Console.WriteLine($"{resource.Name} {resource.ContentLength} {resource.LastModified}");
}
await client.Upload("documents/report.pdf", "report.pdf");
await client.Download("documents/report.pdf", "copy-of-report.pdf");
- Website: https://www.independentsoft.de/webdav/
- Tutorial with C# and VB examples: https://www.independentsoft.de/webdav/tutorial/
- NuGet:
dotnet add package Independentsoft.Webdav
Supported .NET versions
The library targets .NET Standard 2.0, so it runs on:
- .NET 8, .NET 9, .NET 10 and later, .NET 5 to 7, .NET Core 2.0 and later
- .NET Framework 4.6.2 and later (4.7.2 or later recommended)
- Mono, Xamarin and Unity
It has no dependencies besides the .NET libraries.
Features
| Area | What you can do |
|---|---|
| Files and folders | List (also recursively), create, copy, move, rename, delete, check existence, get size, type, dates and ETag |
| Transfer | Upload and download files and streams, with progress reporting and cancellation; resume downloads (Range); update part of a file (Content-Range) |
| Properties | Get, set and remove properties, including XML values, atomically |
| Locking | Exclusive and shared locks on files and folders, refresh, unlock, lock discovery; lock tokens are submitted automatically |
| Concurrency | Conditional requests with ETags (If-Match, If-None-Match) to prevent lost updates or never replace a file |
| Access control | The current user's privileges, owner, access control lists, finding users and groups |
| Synchronization | The changes in a collection since a sync token (sync-collection) |
| Search | basicsearch queries with conditions, sorting and limits |
| Other extensions | Quota, current user principal, extended MKCOL, bindings, ordered collections, versioning, redirect references, mount documents, POST to add members, generic REPORT |
| Errors | WebdavException with the HTTP status, the server's reason (DAV:error condition) and the result for each resource of a 207 Multi-Status |
| Connection | Basic, Digest, NTLM and Negotiate authentication, proxies, client and server certificates, timeouts, cookies, IHttpClientFactory |
Supported specifications
| Specification | Support |
|---|---|
| RFC 4918, HTTP Extensions for WebDAV | PROPFIND, PROPPATCH, MKCOL, GET, PUT, DELETE, COPY, MOVE, LOCK, UNLOCK, OPTIONS; the If header; DAV:error conditions; 207 Multi-Status |
| RFC 9110, HTTP Semantics | Conditional requests (ETags), Range requests |
| RFC 3253, Versioning Extensions (DeltaV) | REPORT, supported-report-set, expand-property, VERSION-CONTROL, CHECKOUT, CHECKIN, UNCHECKOUT, version-tree |
| RFC 3648, Ordered Collections | Ordered collections, ORDERPATCH, Position |
| RFC 3744, Access Control | Privileges, ACL, owner, principal collections, principal-property-search |
| RFC 4331, Quota and Size Properties | quota-available-bytes, quota-used-bytes |
| RFC 4437, Redirect Reference Resources | MKREDIRECTREF, UPDATEREDIRECTREF |
| RFC 4709, Mounting WebDAV Servers | Mount documents (application/davmount+xml) |
| RFC 5323, WebDAV SEARCH | SEARCH with DAV:basicsearch, DASL discovery |
| RFC 5397, Current Principal Extension | current-user-principal |
| RFC 5689, Extended MKCOL | Creating a collection with properties |
| RFC 5842, Binding Extensions | BIND, UNBIND, REBIND, resource-id, 208 Already Reported |
| RFC 5995, POST to Add Members | add-member |
| RFC 6578, Collection Synchronization | sync-collection report, sync tokens |
| RFC 7240 and RFC 8144, Prefer | Prefer: return=minimal for property requests |
Examples
Connect
// Basic, Digest, NTLM or Negotiate, whichever the server asks for.
using var client = new WebdavClient(new NetworkCredential("username", "password"));
client.BaseAddress = new Uri("https://myserver/dav/");
// A proxy, certificates or other connection settings: pass a handler.
var handler = new HttpClientHandler { Credentials = credential, Proxy = new WebProxy("http://proxy:8080") };
using var client2 = new WebdavClient(handler);
Upload and download with progress
var options = new UploadOptions
{
ContentType = "application/pdf",
Progress = new Progress<TransferProgress>(p => Console.WriteLine($"{p.Percentage:0}%"))
};
await client.Upload("documents/report.pdf", "report.pdf", options, cancellationToken);
await client.Download("documents/report.pdf", "report.pdf", options.Progress, cancellationToken);
Prevent lost updates
ResourceInfo file = await client.GetResource("documents/notes.txt");
try
{
await client.Upload("documents/notes.txt", content, new UploadOptions { Precondition = Precondition.IfMatch(file.ETag!) });
}
catch (WebdavException e) when (e.StatusCode == HttpStatusCode.PreconditionFailed)
{
// Someone else changed the file in the meantime.
}
Lock
ActiveLock fileLock = await client.Lock("documents/report.pdf", LockScope.Exclusive, Depth.Zero, TimeSpan.FromMinutes(10));
await client.Upload("documents/report.pdf", "report.pdf"); // the lock token is submitted automatically
await client.Unlock(fileLock);
Properties
var author = new PropertyName("author", "http://example.com/ns");
await client.SetProperty("documents/report.pdf", new Property(author, "John Smith"));
Property? value = await client.GetProperty("documents/report.pdf", author);
Permissions
IReadOnlyList<XName> privileges = await client.GetCurrentUserPrivileges("documents/report.pdf");
bool canWrite = privileges.Contains(DavPrivilege.Write) || privileges.Contains(DavPrivilege.All);
Synchronize
SyncResult changes = await client.SyncCollection("calendars/john/home/", savedToken);
foreach (ResourceInfo changed in changes.Changed) { /* download */ }
foreach (Uri removed in changes.Removed) { /* delete locally */ }
savedToken = changes.SyncToken;
Errors
try
{
await client.Delete("documents/report.pdf");
}
catch (WebdavException e)
{
Console.WriteLine($"{(int)e.StatusCode} {e.ReasonPhrase}, condition: {e.Condition}");
}
More examples, in C# and VB, are in the tutorial.
Upgrading from 1.x
Version 2.0 is a new library with a new API:
| 1.x | 2.0 |
|---|---|
Resource and WebdavSession |
WebdavClient, which owns the connection and credentials |
Synchronous methods returning bool |
async methods returning Task; failures throw WebdavException |
List returning URLs |
List returning ResourceInfo with size, type, dates and ETag |
DownloadProgress, UploadProgress events, Abort() |
IProgress<TransferProgress> and CancellationToken |
GetOutputStream |
Upload(address, stream) |
ActiveLock.Token array |
ActiveLock.Token string, ActiveLock.Root |
Depth string constants |
Depth enum |
HttpWebRequest |
HttpClient |
Building and testing
dotnet build Webdav/Webdav.csproj
dotnet test Webdav.Tests
The unit tests run against a simulated server. To run the server tests too, point them at one or more WebDAV collections the account may write to:
set WEBDAV_TEST_URLS=http://server:9090/;http://server:7070/home/user/
set WEBDAV_TEST_USER=user
set WEBDAV_TEST_PASSWORD=password
set WEBDAV_TEST_USER2=second-user
set WEBDAV_TEST_PASSWORD2=password
dotnet test Webdav.Tests
Each server test runs once for every server and is reported as inconclusive where a server lacks the feature it tests.
The tutorial examples are in Tutorial: python Tutorial/tutorial.py test runs every example, in C# and
VB, against the servers, and python Tutorial/tutorial.py site publishes them as the tutorial pages.
License
WebDAV .NET is a commercial product of Independentsoft. See https://www.independentsoft.de/webdav/ for licensing.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.0 | 40 | 10/6/2026 |
| 1.0.820 | 93 | 10/1/2026 |
| 1.0.800 | 656 | 6/19/2025 |
| 1.0.760 | 259 | 12/22/2024 |
| 1.0.740 | 279 | 6/13/2024 |
| 1.0.720 | 824 | 12/13/2023 |
| 1.0.700 | 783 | 6/13/2023 |
| 1.0.680 | 725 | 12/11/2022 |
| 1.0.660 | 793 | 6/14/2022 |
| 1.0.650 | 1,409 | 12/15/2021 |
| 1.0.640 | 927 | 6/19/2021 |
| 1.0.620 | 2,053 | 12/13/2020 |
| 1.0.600 | 1,283 | 6/18/2020 |
| 1.0.580 | 1,117 | 12/9/2019 |
| 1.0.540 | 1,005 | 9/12/2019 |
| 1.0.530 | 1,052 | 6/6/2019 |
| 1.0.520 | 1,900 | 12/8/2018 |
| 1.0.510 | 1,446 | 9/28/2018 |
| 1.0.500 | 1,246 | 9/21/2018 |
| 1.0.470 | 1,258 | 9/20/2018 |
Version 2.0 is a new library with a new API. WebdavClient replaces Resource and WebdavSession; all request methods are asynchronous and built on HttpClient; errors throw WebdavException with the HTTP status and the server's DAV:error condition. New: progress and cancellation for transfers, resumable downloads, conditional requests (ETags), automatic lock token submission, recursive listing on servers that refuse Depth infinity, access control (RFC 3744), quota (RFC 4331), current user principal (RFC 5397), collection synchronization (RFC 6578), SEARCH (RFC 5323), extended MKCOL (RFC 5689), bindings (RFC 5842), ordered collections (RFC 3648), versioning (RFC 3253), redirect references (RFC 4437), mount documents (RFC 4709), POST to add members (RFC 5995) and Prefer (RFC 8144). See the README for upgrading from 1.x.