我正尝试使用以下代码将文件添加到Sharepoint Office365上我的文档库使用Web服务。Office 365 Sharepoint将文件上传到文档库
public void SaveFileToSharePoint(string fileName)
{
try
{
var copyService = new Copy { Url = "https://mydomain.com/_vti_bin/copy.asmx", Credentials = new NetworkCredential("username", "password", "domain") };
var destURL = "https://mydomain.com/Shared%20Documents/" + Path.GetFileName(fileName);
string[] destinationUrl = { destURL };
CopyResult[] cResultArray;
var fFiledInfo = new FieldInformation { DisplayName = "Description", Type = FieldType.Text, Value = Path.GetFileName(fileName) };
FieldInformation[] fFiledInfoArray = {fFiledInfo};
var copyresult = copyService.CopyIntoItems(destURL, destinationUrl, fFiledInfoArray, File.ReadAllBytes(fileName), out cResultArray);
var b = copyresult;
}
catch (Exception ex)
{
}
}
我收到错误“Object Moved”。 URL通过浏览器加载WSDL。如果有更好的方式在Office365上传并从SharePoint获取文件,我也会这么做。谢谢。
我喜欢这个解决方案的外观,但安全性如何处理?谢谢。 – Cyberdrew
查看我的答案的第二个链接,有一个完整的示例应用程序,尤其是类Tokenhelper应该是您感兴趣的 – roqz
我在哪里可以获得我需要的Microsoft.SharePoint.dll解决方案。我没有安装SharePoint,无法在我的Windows 7计算机上安装WSS以获取它。 – Cyberdrew