Code samples


Download file
WebDavManager webDavManager = new WebDavManager();
webDavManager.DownloadFile("http://localhost/webdav/test.txt", @"C:\Temp\test.txt");

Upload file
WebDavManager webDavManager = new WebDavManager();
webDavManager.UploadFile("http://localhost/webdav/uploadTest.txt", @"C:\Temp\test.txt");

Create directory
WebDavManager webDavManager = new WebDavManager(new WebDavCredential("user", "password"));
webDavManager.CreateDirectory("http://localhost/webdav/NewDir/");

Delete directory/file
WebDavManager webDavManager = new WebDavManager(new WebDavCredential("user", "password"));
webDavManager.Delete("http://localhost/webdav/NewDir/");

List directory
WebDavManager webDavManager = new WebDavManager();
List<WebDavResource> webDavResources =  webDavManager.List("http://localhost/webdav/");

foreach (WebDavResource resource in webDavResources)
{
   Console.WriteLine("Name: " + resource.Name);
   Console.WriteLine("Size: " + resource.Size);
   Console.WriteLine("Url: " + resource.Url);
   Console.WriteLine("Created: " + resource.Created);
   Console.WriteLine("Modified: " + resource.Modified);
   Console.WriteLine("* End of resource *");   
}

Copy directory/file
WebDavManager webDavManager = new WebDavManager(new WebDavCredential("user", "password"));
webDavManager.Copy("http://localhost/webdav/sourceTest.txt", "http://localhost/webdav/targetTest.txt");

Move directory/file (Rename)
WebDavManager webDavManager = new WebDavManager(new WebDavCredential("user", "password"));
webDavManager.Move("http://localhost/webdav/sourceTest.txt", "http://localhost/webdav/targetTest.txt");

Check directory/file exists
WebDavManager webDavManager = new WebDavManager();
bool exists = webDavManager.Exists("http://localhost/webdav/test.txt");

Console.WriteLine("Resource exists: " + exists);

Last edited Sep 21, 2009 at 2:28 PM by tloehlein, version 5

Comments

No comments yet.