You are here: home » projects » webdav

WebDAV client for basic file transfer operations

News

Summary

The WebDAV standard allows users to edit and manage files collaboratively on a webserver.

WebDAV replaces FTP

Where FTP communication often presents firewall/NAT challenges, WebDAV works on the standard HTTP port 80 (or HTTPS). That's all this library aims for. Simple file transfers over HTTP using WebDAV.

Features and compatibility

The client can:

All operations have been tested successfully on these servers:

License

The code is CC0 licensed. Feel free to use this code however you like.

Download

The project files including tests: git tree | download as zip

Examples

First, setup the connection:

WebDAVClient c = new WebDAVClient();
c.User = "yourusername";
c.Pass = "yourpassword";
c.Server = "http://www.yourserver.com";
c.BasePath = "/webdav";

Then, use it asynchronously:

// List all files and directories on the WebDAV share
c.ListComplete += new ListCompleteDel(c_ListComplete);
c.List();

...

void c_ListComplete(List<string> files, int statusCode)
{
    // Here's the list of files
}

Or, use synchronous (blocking) operations:

AutoResetEvent autoResetEvent;

...

// Upload a file from c:\file.txt to http://www.yourserver.com/webdav/file.txt
autoResetEvent = new AutoResetEvent(false);
c.UploadComplete += new UploadCompleteDel(c_UploadComplete);
c.Upload(@"c:\file.txt", "file.txt");
autoResetEvent.WaitOne();
// File has been uploaded at this point

void c_UploadComplete(int statusCode)
{
    autoResetEvent.Set();
}

Feedback

Feel free to send your feedback and patches. (You might want to leave your email address.)


last modified on 2009-07-18 @ 13:54