Copy.CopyIntoItems Method
[SoapDocumentMethodAttribute("http://schemas.microsoft.com/sharepoint/soap/CopyIntoItems", RequestNamespace="http://schemas.microsoft.com/sharepoint/soap/", ResponseNamespace="http://schemas.microsoft.com/sharepoint/soap/", Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped)] public uint CopyIntoItems ( string SourceUrl, string[] DestinationUrls, FieldInformation[] Fields, byte[] Stream, out CopyResult[] Results )
Parameters
- SourceUrl
A String that contains the absolute source URL of the document to be copied.
- DestinationUrls
An array of Strings that contain one or more absolute URLs specifying the destination location or locations of the copied document.
- Fields
An array of FieldInformation objects that define and optionally assign values to one or more fields associated with the copied document.
- Stream
An array of Bytes that contain the document to copy using base-64 encoding.
- Results
An array of CopyResult objects, passed as an out parameter.
Return Value
A UInt32 that returns 0 to indicate that the operation has completed. (There is also an out parameter containing an array of CopyResult objects.)Use the GetItem method to generate a Byte array of the document, and then pass it as the Stream parameter to the CopyIntoItems method to copy the array into a document on the destination server.
SourceUrl is not used in the copy operation but is stored with the document on the server as the CopySource property. This enables users of the copy to navigate back to the source.
The following example copies a document from one server running Windows SharePoint Services to two locations on a different server.
Web_Reference_Name.Copy myCopyService = new Web_Reference_Name.Copy(); myCopyService.Credentials = System.Net.CredentialCache.DefaultCredentials; string copySource = "http://Server1/Site1/Shared Documents/test.txt"; string[] copyDest = { "http://Server2/Site1/Shared Documents/test.txt", "http://Server2/Site2/Shared Documents/test.txt" }; Web_Reference_Name.FieldInformation myFieldInfo = new Web_Reference_Name.FieldInformation(); Web_Reference_Name.FieldInformation[] myFieldInfoArray = { myFieldInfo }; byte[] myByteArray; uint myGetUint = myCopyService.GetItem(copySource, out myFieldInfoArray, out myByteArray); Web_Reference_Name.CopyResult myCopyResult1 = new Web_Reference_Name.CopyResult(); Web_Reference_Name.CopyResult myCopyResult2 = new Web_Reference_Name.CopyResult(); Web_Reference_Name.CopyResult[] myCopyResultArray = { myCopyResult1, myCopyResult2 }; try { uint myCopyUint = myCopyService.CopyIntoItems(copySource, copyDest, myFieldInfoArray, myByteArray, out myCopyResultArray); if (myCopyUint == 0) { int idx = 0; foreach (Web_Reference_Name.CopyResult myCopyResult in myCopyResultArray) { string opString = (idx+1).ToString(); if (myCopyResultArray[idx].ErrorMessage == null) { MessageBox.Show("Copy operation " + opString + "completed.\r\n" + "Destination: " + myCopyResultArray[idx].DestinationUrl); } else { MessageBox.Show("Copy operation " + opString + " failed.\r\n" + "Error: " + myCopyResultArray[idx].ErrorMessage + "\r\n" + "Code: " + myCopyResultArray[idx].ErrorCode); } idx++; } } } catch (Exception exc) { int idx = 0; foreach (Web_Reference_Name.CopyResult myCopyResult in myCopyResultArray) { idx++; if (myCopyResult.DestinationUrl == null) { string idxString = idx.ToString(); MessageBox.Show("Copy operation " + idxString + " failed.\r\n" + "Description: " + exc.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }