Welcome to MSDN Blogs Sign in | Join | Help

David Szabo's [MSFT] blog

A Consultant's Diary
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);
Posted: Sunday, August 12, 2007 5:00 PM by dszabo

Comments

Daniel said:

very much off topic, but whats the point of having "pingbacks" from other sits, who have just copied and pasted your content....

Isnt the whoel idea and concept of WSS/MOSS so you dont have to duplicate information?

I would post this on the other site also, however they dont allow comments.

Regards,

Daniel

# August 27, 2007 7:44 PM

Avi said:

What shd be the destinationURL if my Shared Documents URL is

http://my_server_name/Shared%20Documents/Forms/AllItems.aspx

Regards,

Avi.

# February 5, 2008 5:24 AM

dszabo said:

# March 16, 2008 10:18 AM

Johan said:

Thank you for the code snippets.

After the upload of the document, it is in a "checked out" status. Is there a simple way to indicate that the document should be marked as "checked in"?

Regards,

Johan.

# October 24, 2008 10:01 AM

dszabo said:

Hey Johan,

You need to use the object model or MOSS web services to check the document back in. See http://msdn.microsoft.com/en-us/library/lists.lists.checkinfile.aspx for an example!

Chrs,

David

# October 25, 2008 3:27 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker