Useful WSS 3.0 Samples

In Dublin it's always raining, so there's always some time to post a new article. Two useful code snippets for WSS3 developers: 

Smartly export a document from a WSS Document Library:

 // Set up the webclient with the correct credentials
WebClient webClient = new System.Net.WebClient();
webClient.Credentials = credential;

// Export the document to the given folder 
webClient.DownloadFile(documentUrl, docFullPath);

Smartly import (upload) a document to a WSS Document Library:

 // Set up the webclient with the correct credentials
WebClient webClient = new System.Net.WebClient();
webClient.Credentials = credential;

// Upload the file
webClient.UploadFile(destinationUrl, "PUT", sourceFilePath);

Comments