Copy.CopyIntoItemsLocal method

Copies a document from one location on a server running Microsoft SharePoint Foundation to another location on the same server.

Namespace:  WebSvcCopy
Assembly:  STSSOAP (in STSSOAP.dll)

Syntax

'Declaration
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/CopyIntoItemsLocal", RequestNamespace := "https://schemas.microsoft.com/sharepoint/soap/",  _
    ResponseNamespace := "https://schemas.microsoft.com/sharepoint/soap/",  _
    Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Function CopyIntoItemsLocal ( _
    SourceUrl As String, _
    DestinationUrls As String(), _
    <OutAttribute> ByRef Results As CopyResult() _
) As UInteger
'Usage
Dim instance As Copy
Dim SourceUrl As String
Dim DestinationUrls As String()
Dim Results As CopyResult()
Dim returnValue As UInteger

returnValue = instance.CopyIntoItemsLocal(SourceUrl, _
    DestinationUrls, Results)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/CopyIntoItemsLocal", RequestNamespace = "https://schemas.microsoft.com/sharepoint/soap/", 
    ResponseNamespace = "https://schemas.microsoft.com/sharepoint/soap/", 
    Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public uint CopyIntoItemsLocal(
    string SourceUrl,
    string[] DestinationUrls,
    out CopyResult[] Results
)

Parameters

  • SourceUrl
    Type: System.String

    A String that contains the absolute source URL of the document to be copied.

  • DestinationUrls
    Type: []

    An array of Strings that contain one or more absolute URLs specifying the destination location or locations of the copied document.

  • Results
    Type: []

    An array of CopyResult objects, passed as an out parameter.

Return value

Type: System.UInt32
A UInt32 that returns 0 to indicate that the operation has completed. (There is also an out parameter containing an array of CopyResult objects.)

Remarks

The DestinationUrls must be on the same server as the SourceUrl and the server to which the SOAP request is sent.

There is one CopyResult in Results for each URL in DestinationUrls.

Note

The values of lookup fields are not copied when the target is a different site collection from the source.

Examples

The following example copies a document on a server running Microsoft SharePoint Foundation to two other locations on the same server.

Dim myCopyService As New Web_Reference_Name.Copy()
myCopyService.Credentials = _
    System.Net.CredentialCache.DefaultCredentials

Dim copySource As String = _
    "http://Server1/Site1/Shared Documents/test.txt"
Dim copyDest As String() = _
    {"http://Server1/Site2/Shared Documents/test.txt", _
    "http://Server1/Site3/Shared Documents/test.txt"}

Dim myCopyResult1 As New Web_Reference_Name.CopyResult()
Dim myCopyResult2 As New Web_Reference_Name.CopyResult()
Dim myCopyResultArray As Web_Reference_Name.CopyResult() = _
    {myCopyResult1, myCopyResult2}

Try
    Dim myUint As System.UInt32 = _
    myCopyService.CopyIntoItemsLocal(copySource, copyDest, _
        myCopyResultArray)
    If myUint = 0 Then
        Dim idx As Integer = 0
        Dim myCopyResult As Web_Reference_Name.CopyResult
        For Each myCopyResult In myCopyResultArray
            Dim opString As String = (idx + 1).ToString()
            If myCopyResultArray(idx).ErrorMessage Is Nothing Then
                MessageBox.Show(("Copy operation " + opString + " _
                    completed." + ControlChars.Cr + ControlChars.Lf + _
                    "Destination: " + _
                    myCopyResultArray(idx).DestinationUrl))
            Else
                MessageBox.Show(("Copy operation " + opString + " _
                    failed." + ControlChars.Cr + ControlChars.Lf + _
                    "Error: " + myCopyResultArray(idx).ErrorMessage + _
                    ControlChars.Cr + ControlChars.Lf + "Code: " + _
                    myCopyResultArray(idx).ErrorCode))
            End If
            idx += 1
        Next myCopyResult
    End If
Catch exc As Exception
    Dim idx As Integer = 0
    Dim myCopyResult As Web_Reference_Name.CopyResult
    For Each myCopyResult In myCopyResultArray
        idx += 1
        If myCopyResult.DestinationUrl Is Nothing Then
            Dim idxString As String = idx.ToString()
            MessageBox.Show("Copy operation " + idxString + _
                " failed." + ControlChars.Cr + ControlChars.Lf + _
                myCopyResult.ErrorMessage + myCopyResult.ErrorCode + _
                "Description: " + exc.Message, "Exception", _
                MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If
    Next myCopyResult
End Try
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://Server1/Site2/Shared Documents/Test.txt, 
    "http://Server1/Site3/Shared Documents/Test.txt " };

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 myUint = myCopyService.CopyIntoItemsLocal(copySource, 
        copyDest, out myCopyResultArray);
    if (myUint == 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" +myCopyResult.ErrorMessage + 
                myCopyResult.ErrorCode +
                "Description: " + exc.Message,
                "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
    }    
}

See also

Reference

Copy class

Copy members

WebSvcCopy namespace