Erika Ehrli - Adventures with Office Products & Technologies

MSDN & TechNet: Releasing Office, SharePoint, Exchange & Lync Centers and content for developers and IT professionals. News, technical articles, code samples, training, and learning resources.

How to: Uploading a File to a SharePoint Library Site from a Local Folder

How to: Uploading a File to a SharePoint Library Site from a Local Folder

  • Comments 62

I am currently developing an application that will help my team (Office Developer Documents) to manage all the metadata associated with the publishing process in MSDN. The name of the tool is Rawhide and it’s a Web-based application. I am really excited of developing this tool because I am working with Whidbey, ASP.NET 2.0, SQL Server, Windows Sharepoint Services, and a cool set Office development features. Soon I will start adding Office “12” enhancements such as Excel Services and Windows Sharepoint Services “v3”. I can’t wait!

I am learning a lot from my peers about how interesting it is to publish content in MSDN and I hope this tool will improve our working experience and become a great source of code snippets that I can share with the community.

Today I was reading the newsgroups and I was looking at lots of posts where developers are looking for code that will help to upload programmatically files to a SharePoint library. I was surprised to see that there are lots of developers struggling with this issue. I am too :). One of Rawhide’s features is to submit our articles, code samples, and art to a SharePoint Library.

I found two great articles that are helping me out to accomplish my mission. I know there are many ways of doing that, but this is the recommended one by Microsoft and I love it because it has just what I needed and it has code in C# and VB.NET:

Uploading a File to a SharePoint Site from a Local Folder

I also found this page that has all the information I need to work with the SPFileClass.

And finally, I found this interesting blog entry at Bill Simser’s blog where he talks about the Syncronization of Office Document Properties with WSS Document Libraries. I haven't tested this yet, but apparently, if you create the following properties in a Sharepoint library or list:

Hyperlink base

"The MS/Office documents that are upload inherit such corresponding custom MS/Office properties : "


As soon as I complete my "upload files to SharePoint" features in Rawhide, I will keep you posted with the outcome.

Leave a Comment
  • Please add 5 and 4 and type the answer here:
  • Post
  • I too noticed a lot of requests for uploading files. I posted a code snippet on my weblog (

  • I saw that! Thanks for sharing and writing about that, I was quite surprised too.
  • When we try to use the code as mentioned in the msdn I am being asked for credentials. What permissions do I need.

    This works only if I am an administrator on the machine.
  • I think there is confusion on what you need to reference. Do I have to develop and run a windows app written in c# on a server that has Sharepoint installed to use the local dlls? I can easily use http://rmcazpts01/_vti_bin/Dws.asmx as a web reference to create folders in SharePoint but there is no outright "Upload File" web services. The only thing that sounds close is UpdateDwsData and this is the only option in dws.asmx that does not have a code example. Please explain if you can. The guys blog underneath yours also doesn't explain what you need to reference either. I don't want a web application.
  • Hi everyone,

    Thanks for your comments and questions. I talked to the product team and another option to upload documents to a SharePoint v2 library is building a custom web service. Here is how:

    This scenario works well when you are trying to upload a document to a document library that lives in a different web server from your web-based application.

    About security, make sure that the user that gets impersonated (if you are using Windows Authentication) has write permissions at the SharePoint library. This is a matter of authorization.
  • Wait a minute guys. I'm a regular old everyday user. Do you mean to tell me that my "UPLOAD FILE" button in Sharepoint won't allow me to upload a few MS Word and Acrobat files from a CD in my "E" drive unless I use the computer code that you are using?

    When I attempt to upload my files from the CD Sharepoint wants me to browse the CD folders and select one file at a time.  This is totally impossible. I have some 60 files.

  • Wait a minute guys. I'm a regular old everyday scripter.

    I don't own the SharePoint server; I don't want to use a web browser.

    I want to write code once to upload one or more files and have it run whenever it should run. If there is a web service to get a list of versions of a file, why isn't there a web service to upload a new version?
  • Errol-

    After much searching, I found the scripting information that I needed. You could use it for exactly what you need if you are capable of a little VBScript-ing. (msxml2 and adodb are Microsoft libraries that most systems would have installed with various products.)

    I hope this helps you. Sorry, I don't have time right now to write you an example.

  • I downloaded the code sample from the following location:


    I can tell you I have an ASP.NET 2.0 application in production that is using the web service and it's quite smooth and easy to configure.

    You just need to:
    1. Run the .bat inside the download.
    2. Add a reference to the web service from your project.
    3. Turn on impersonation
    4. Add permissions to the users that will be uploading documents to the SharePoint Document Library.
    5. Be happy and smile because it works!
  • After doing some research and some tests, I found a very easy way to do that and now I want to share with you the approach I followed since you might find it useful as well.
  • Not to pick on you, Erika, but Microsoft just doesn't get it. Quit making addons that constitute patches; start making service packs.

    SharePoint users should not need to ask SharePoint administrators to install addons; At worst, they should only have to ask them to upgrade to a current, Microsoft-supported version that is a complete product. By complete, I mean that anything that can be done by a user through a web browser should be able to be done by a *user* application that consumes a web service that is part of the product.

    Anyway, keep up the enthusiatic sharing of addon information--some SharePoint developer/adminstrators will find it very useful.
  • i want to upload a file from my local folder to a sharepoint server which is on some other machine......will the above program works for it?.....Thanx for any help......
  • I need the exact C#.Net coding for uploading a file from local folder to sharepoint document library
  • Hi,

    Office 2003, WSS2.0

    We're currently customizing WORD for a group of policy analysts.  Their current way of operating is to use Word to open files stored on a file server.  We are looking at using SP as the document store because of its checkin, check-out and versioning.  I think, based on the article(, that we can integrate the checkin, checkout.  

    What about versioning?  Any examples out there?  I've looked, very briefly at http://<servername>/_vti_bin/versions.asmx.  I was expecting something called "add version" or something like that.  Is there a way to handle versioning of documents in a similar way?

    Thanks for any assistance,


  • How about uploading a new workbook to sharepoint via an excel macro? any helpon that???

Page 1 of 5 (62 items) 12345