文件服务器迁移sharepoint,文件从Web应用程序上载到Sharepoint服务器

使用Sharepoint提供的Web服务(CopyIntoItems)

使用Sharepoint webservice的jQuery库

醇>

搜索网页后,我认为jQuery部分不起作用(你可以纠正我)。

我正在寻找一种获取用户名/密码并将pdf文件上传到Sharepoint服务器的方法。以下是我尝试上传但最终错误的C#代码

public bool UploadFile(string file, string destination)

{

bool success = false;

CopySoapClient client = new CopySoapClient();

if (client.ClientCredentials != null)

client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;

try

{

client.Open();

string filename = Path.GetFileName(file);

string destinationUrl = destination + filename;

string[] destinationUrls = { destinationUrl };

FieldInformation i1 = new FieldInformation { DisplayName = "Title", InternalName = "Title", Type = FieldType.Text, Value = filename };

FieldInformation[] info = { i1 };

CopyResult[] result;

byte[] data = File.ReadAllBytes(file);

//uint ret = client.CopyIntoItems(filename, destinationUrls, info, data, out result);

uint ret = client.CopyIntoItems(file, destinationUrls, info, data, out result);

if (result != null && result.Length > 0 && result[0].ErrorCode == 0)

success = true;

}

finally

{

if (client.State == System.ServiceModel.CommunicationState.Faulted)

client.Abort();

if (client.State != System.ServiceModel.CommunicationState.Closed)

client.Close();

}

return success;

}

我正在调用上面的函数

UploadFile(@"C:\temp\uploadFile.txt", "http://spf-03:300/demo/Dokumente").ToString();

我得到的错误:

错误代码:目标无效

错误消息:必须在包含目标URL的同一域上调用服务方法“Copy”。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值