Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
W

WebDavClient

> 开发工具
Open source

Asynchronous cross-platform WebDAV client for .NET Core

186 stars0 likes1 views
WebsiteGitHub

About

Asynchronous cross-platform WebDAV client for .NET Core

WebDAV .NET client

Asynchronous cross-platform WebDAV client for .NET Core and other runtimes. It aims to have a full support of RFC4918.

Installation

Install WebDav.Client via NuGet.

Install-Package WebDav.Client

Supported platforms

  • .NET Core 1.0+
  • .NET Framework 4.5+
  • Mono
  • Xamarin
  • UWP

For more information see .NET Standard.

Usage notes

WebDavClient uses HttpClient under the hood that is why it is a good practice to share a single instance for the lifetime of the application.

If you use a dependency injection container to manage dependencies it is a good practice to register WebDavClient as a singleton.

It's also possible to instantiate WebDavClient with a pre-configured instance of HttpClient.

When using GetRawFile / GetProcessedFile don't forget to dispose the response.

Usage examples

Basic usage

csharp
class Example
{
    public static IWebDavClient _client = new WebDavClient();

    public void MakeCalls()
    {
        var result = await _client.Propfind("http://mywebdav/1.txt");
        if (result.IsSuccessful)
            // continue ...
        else
            // handle an error
    }
}

Using BaseAddress

csharp
var clientParams = new WebDavClientParams { BaseAddress = new Uri("http://mywebdav/") };
using (var client = new WebDavClient(clientParams))
{
    await client.Propfind("1.txt");
}

Operations with files and directories (resources & collections)

…

Authentication using an access token

csharp
var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Authorization = 
    new AuthenticationHeaderValue("Bearer", accessToken);
var client = new WebDavClient(httpClient);

Authentication using NetworkCredential

csharp
var clientParams = new WebDavClientParams
{
    BaseAddress = new Uri("http://mywebdav/"),
    Credentials = new NetworkCredential("user", "12345")
};
var client = new WebDavClient(clientParams);

PROPFIND example

csharp
// list files & subdirectories in 'mydir'
var result = await _client.Propfind("http://mywebdav/mydir");
if (result.IsSuccessful)
{
    foreach (var res in result.Resources)
    {
        Trace.WriteLine("Name: " + res.DisplayName);
        Trace.WriteLine("Is directory: " + res.IsCollection);
        // etc.
    }
}

PROPFIND with custom properties

csharp
var propfindParams = new PropfindParameters
{
    Namespaces = new [] { new NamespaceAttr("myns", "https://example.com/") },
    CustomProperties = new [] { XName.Get("myprop", "https://example.com/") }
};
var result = await client.Propfind("http://mywebdav/mydir", propfindParams);

Custom headers

csharp
var propfindParams = new PropfindParameters
{
    Headers = new List>
    {
        new KeyValuePair("User-Agent", "Not a browser")
    }
};
var result = await _client.Propfind("http://mywebdav/1.txt", propfindParams);

Content-Range or other content headers

csharp
// Content headers need to be set directly on HttpContent instance.
var content = new StreamContent(File.OpenRead("test.txt"));
content.Headers.ContentRange = new ContentRangeHeaderValue(0, 2);
var result = await _client.PutFile("http://mywebdav/1.txt", content);

Synchronous API

csharp
  // will block the current thread, so use it cautiously
  var result = _client.Propfind("1.txt").Result;

License

WebDavClient is licensed under the MIT License. See LICENSE.txt for more details.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C#c-sharpdotnetdotnet-coredotnet-standard

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category开发工具
PricingOpen source

> Related tools

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具