SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using C# in Visual Studio with a Silverlight app. I want to upload a file to a document library, but none of the web-services here seem to have a way to do this.

I'm not using object model, only service references to the .asmx's in that link.

Thanks for any help/suggestions you can offer

share|improve this question
up vote 6 down vote accepted

After searching for a solution to this all week I finally found a web-service call that works with it. Here is how I solved this problem: (SharepointCopy is my service reference to copy.asmx)

   public void UploadFile(String fileName, byte[] file)

        string[] destinationUrls = {"http://[server]/sites/[listName]/"+fileName}; 

        // load the file into a file stream

        byte[] fileBytes = file;

        // fill out the metadata
        // remark: don't set the Name field, because this is the name of the document

        SharepointCopy.FieldInformation titleInformation = new SharepointCopy.FieldInformation
            {DisplayName ="Title", 
             InternalName ="Title", 
             Type = SharepointCopy.FieldType.Text, 
             Value ="Test1Title"};

        // to specify the content type

        SharepointCopy.FieldInformation ctInformation = new   SharepointCopy.FieldInformation
            {DisplayName ="Content Type", 
             InternalName ="ContentType", 
             Type = SharepointCopy.
             Value ="Your content type"};

        SharepointCopy.FieldInformation[] metadata = { titleInformation }; 

        // initialize the web service

        SharepointCopy.CopySoapClient copyws = new SharepointCopy.CopySoapClient(); 

        // execute the CopyIntoItems method
        copyws.CopyIntoItemsCompleted += copyws_CopyIntoItemsCompleted;
        copyws.CopyIntoItemsAsync("http://null", destinationUrls, metadata, fileBytes);


Many Thanks to Karine Bosch for the solution here:

share|improve this answer
this answer shows code snippet that never uses variable ctInformation. – barrypicker Jan 5 '15 at 16:44

Uploading a document can be done using a HTTP PUT command, for example using WebClient and the UploadData method.

share|improve this answer
I know, but I don't know how to do an HTTP PUT in silverlight because silverlight limits http messages to GET and POST by default. How can I allow PUT calls? – Anonymous Mar 11 '10 at 16:12
Are you sure about this. You have access to the WebClient class in SL so an UploadData(address, "PUT", bytes); would work? See – Wictor Wilen MCA MCM MVP Mar 11 '10 at 16:40
I know it says you can question in the first comment was how do I enable it? In SL UploadData is not available (at least by default). It only has UploadStringAsync for the WebClient – Anonymous Mar 11 '10 at 17:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.