Copy files using SharePoint web service

we can use the inbuilt sharepoint webservice to copy the files from one site to another in under same webapplication, or you can go with client object model as well.

1. Lists.asmx: To get all folders and lists.
2. DWS.asmx: we can create folders and files
3. Copy.aspx: To copy files from one library to another this is easy one

This Copy Web service plays the role of copying, and moving documents with the field information’s. There are three classes to play this role

This Copy Web service plays the role of copying, and moving documents with the field information’s. There are three classes to play this role

Copy: Provides methods for copying files between SharePoint sites or within a SharePoint site.

CopyResult: Represents the result of a copy operation.

FieldInformation: Provides properties that define a field associated with a document copied by using a Copy web service operation.

The three methods within Copy class do the job for us to move the files in SharePoint libraries,

GetItem: Generates a Byte array representation of a document that can be passed to the CopyIntoItems method to copy the document to a different server.

CopyIntoItems: Copies a document represented by a Byte array to one or more locations on a server.

CopyIntoItemLocal: Copies a document from one location on a server running Windows SharePoint Services to another location on the same server.

would be glad to assist further, plz. Let me know if you face any issue or you need the client object model code to copy files one location to another.

byte[] xmlByteArray;

using (MemoryStream memoryStream = new MemoryStream())



xmlBytes = memoryStream.ToArray();


string destinationUrl = “http://webserver/site/Doclib/UploadedDocument.xml”

string[] destinationUrlArray = new string[] { destinationUrl };

FieldInformation allFieldInfo = new FieldInformation();

FieldInformation[] fields = { allFieldInfo };

CopyResult[] resultsArray;

using (Copy copyService = new Copy())


copyService.Credentials = CredentialCache.DefaultCredentials;

copyService.Url = “http://webserver/site/_vti_bin/copy.asmx”;

copyService.Timeout = 600000;

uint documentId = copyService.CopyIntoItems(destinationUrl , destinationUrlArray, fields, xmlByteArray, out resultsArray);



The file data is retrieved in the output parameter Stream. “Stream: An array of Bytes, passed as an out parameter that is a base-64 representation of the retrieved document’s binary data.”

If we see the performance perspective we have some overheads here are:

  • Marshalling/un-marshalling: The SharePoint Server encodes the binary file data (e.g. Word, Excel file) into text (using Base64 encoding) in order to send it over Web Service. The client application should decode it back to the original encoding for viewing the file. This can affect performance.


  • Memory overhead: The copyService.CopyIntoItems() method uses a single buffer to retrieve the whole file content. In SharePoint, the maximum allowed size of a single file for upload is 50 MB by default. But this can be configured and the theoretical limit of file size in SharePoint is 2 GB. So having a single buffer to download a file is not practical due to obvious reasons.


About Krishana Kumar

Krishana Kumar is SharePoint Architect/Trainer having Architecture experience with high volumes at Enterprise level and global scale - creation of highly scalable solutions with global user base and geographically distributed architectural components. Good knowledge of SharePoint best practices and governance models. I hold Two Master degree in Computer Science with over 11 years of experience working on Microsoft Technologies specially SharePoint, Project, .NET and other Information Worker Technologies. Having good exposer in Client side scripting Angular.js, backbone and Node. I am currently responsible for SharePoint Infrastructure set up and leading teams in various medium and large scale projects, architecting, designing & installing SharePoint farms, developing custom components,, and providing advanced SharePoint administration and development training to teams and customers. I regularly speaks in various SharePoint User Groups and other Events. I have MCSA Windows Azure, MCSA Office 365, MCSE & MCSD SharePoint 2013, Microsoft Certified Developer (MCD) and holds MCPD, MCTIP and MCTS for SharePoint 2010, MCTS MOSS 2007 & WSS 3.0, MCPD, MCITP (EPM 2010 & 2007) and MCSD .NET.
This entry was posted in General Interest. Bookmark the permalink.