How do you copy a file into SharePoint using a WebService?

后端 未结 10 1489
执念已碎
执念已碎 2020-12-10 06:45

I am writting a winforms c# 2.0 application that needs to put an XML file into a document library on SharePoint.

I want to use a WebService instead of using the ob

10条回答
  •  一整个雨季
    2020-12-10 07:11

    your code is fine, just use the destination url instead of an empty string. See below:

    byte[] xmlByteArray;
    using (MemoryStream memoryStream = new MemoryStream())
    {
        xmlDocument.Save(memoryStream);
        xmlBytes = memoryStream.ToArray();
    }
    
    string destinationUrl = “http://webserver/site/Doclib/UploadedDocument.xml”
    string[] destinationUrlArray = new string[] { destinationUrl };
    
    FieldInformation fieldInfo = new FieldInformation();
    FieldInformation[] fields = { fieldInfo };
    
    
    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);
    }
    

提交回复
热议问题