Mat*_*ley 4 .net c# sharepoint web-services
我正在尝试使用SharePoint Copy Web服务的CopyIntoItems方法将文档文件加载到SharePoint中的文档库中.
下面的代码执行并返回0(成功).此外,CopyResult []数组返回1个带有"Success"结果的值.但是,我无法在库中的任何位置找到该文档.
我有两个问题:
代码示例:
string[] destinationUrls = { Uri.EscapeDataString("https://someaddress.com/Reports/Temp") };
SPCopyWebService.FieldInformation i1 = new SPCopyWebService.FieldInformation { DisplayName = "Name", InternalName = "Name", Type = SPListTransferSpike1.SPCopyWebService.FieldType.Text, Value = "Test1Name" };
SPCopyWebService.FieldInformation i2 = new SPCopyWebService.FieldInformation { DisplayName = "Title", InternalName = "Title", Type = SPListTransferSpike1.SPCopyWebService.FieldType.Text, Value = "Test1Title" };
SPCopyWebService.FieldInformation[] info = { i1, i2 };
SPCopyWebService.CopyResult[] result;
byte[] data = File.ReadAllBytes("C:\\SomePath\\Test1Data.txt");
uint ret = SPCopyNew.CopyIntoItems("", destinationUrls, info, data, out result);
Run Code Online (Sandbox Code Playgroud)
编辑让事情有效:
我通过在SourceUrl字段中添加" http:// null "来使我的代码正常工作.Nat的答案可能就是出于这个原因.这是我改变它以使其工作的线.
// Change
uint ret = SPCopyNew.CopyIntoItems("http://null", destinationUrls, info, data, out result);
Run Code Online (Sandbox Code Playgroud)
我认为问题可能在于尝试使用webservice设置"Name"属性.我做了一些失败.鉴于"名称"是文档的名称,您可能会取得一些成功
string targetDocName = "Test1Name.txt";
string destinationUrl = Uri.EscapeDataString("https://someaddress.com/Reports/Temp/" + targetDocName);
string[] destinationUrls = { destinationUrl };
SPCopyWebService.FieldInformation i1 = new SPCopyWebService.FieldInformation { DisplayName = "Title", InternalName = "Title", Type = SPListTransferSpike1.SPCopyWebService.FieldType.Text, Value = "Test1Title" };
SPCopyWebService.FieldInformation[] info = { i1};
SPCopyWebService.CopyResult[] result;
byte[] data = File.ReadAllBytes("C:\\SomePath\\Test1Data.txt");
uint ret = SPCopyNew.CopyIntoItems(destinationUrl, destinationUrls, info, data, out result);
Run Code Online (Sandbox Code Playgroud)
注意:我使用"目标"作为"源"属性.不太清楚为什么,但它确实可以解决问题.
| 归档时间: |
|
| 查看次数: |
17085 次 |
| 最近记录: |