>C# – Uploading file to Sharepoint Document Library using Web Services without Sharepoint SDK

>Creating Proxy Class for Copy.asmx

1) Go to Visual Studio Tools – > Open Visual Studio Command Prompt
2) Type wsdl “http://%5Bsharepoint server]/_vti_bin/Copy.asmx, this would generate a Copy.cs class that we’ll be using later.
3) Add the Copy.cs to the Visual Studio solution.

Modifying Copy.cs

1) Open the Copy.cs and add a namespace. Ex. MyPOC.SharepointServices
2) Go to Copy Constructor. If the SP site needs authentication you need
to add this line:
this.Credentials = new System.Net.NetworkCredential(“[username]”, “[password]”, “[domain]” )

Uploading the File

MyPOC.SharepointServices.Copy copy = new Copy();
FieldInformation[] info = new FieldInformation[] { new FieldInformation()} ;
string url = “http://anyurl”;
string destUrl = new string[] {“http://sharepointserver/%5Bcomplete path of document library]”};

string fileToUpload = “c:\test.doc”;

CopyResult[] results;

copy.CopyIntoItems(url,dest,info,File.ReadAllBytes(fileToUpload), out results);