【发布时间】:2013-10-17 21:08:33
【问题描述】:
我有来自http://ktskumar.wordpress.com/2009/03/03/upload-document-from-local-machine-to-sharepoint-library/ 的以下代码,用于使用 Web 服务将文档上传到共享点库。我已添加 https://mysite.sharepoint.com/_vti_bin/Copy.asmx(此站点位于 sharepoint Online 上)作为我的服务参考。
//Copy WebService Settings
string webUrl = "https://mySite.sharepoint.com";
WSCopy.Copy copyService = new WSCopy.Copy();
copyService.Url = webUrl + "/_vti_bin/copy.asmx";
copyService.Credentials = System.Net.CredentialCache.DefaultCredentials;
//Source and Destination Document URLs
string sourceUrl = "http://localhost/Shared Documents/Sample.doc";
string destinationUrl = "E:\\DocumentsSample.doc";
//Variables for Reading metadata’s of a document
WSCopy.FieldInformation fieldInfo = new WSCopy.FieldInformation();
WSCopy.FieldInformation[] fieldInfoArray = { fieldInfo };
WSCopy.CopyResult cResult1 = new WSCopy.CopyResult();
WSCopy.CopyResult cResult2 = new WSCopy.CopyResult();
WSCopy.CopyResult[] cResultArray = { cResult1, cResult2 };
//Receive a Document Contents into Byte array (filecontents)
byte[] fileContents = new Byte[4096];
uint copyresult = copyService.GetItem(sourceUrl, out fieldInfoArray, out fileContents);
if (copyresult == 0)
{
Console.WriteLine("Document downloaded Successfully, and now it's getting saved in location " + destinationUrl);
//Create a new file and write contents to that document
FileStream fStream = new FileStream(destinationUrl, FileMode.Create, FileAccess.ReadWrite);
fStream.Write(fileContents, 0, fileContents.Length);
fStream.Close();
}
else
{
Console.WriteLine("Document Downloading gets failed...");
}
Console.Write("Press any key to exit...");
Console.Read();
这里 WSCopy 是服务引用,在我的项目中找不到“WSCopy.Copy”复制类。我该如何解决这个问题,或者有其他方法可以实现我的目标。
【问题讨论】:
-
我认为 asmx 网络服务在 SP 2013 中是 deprecated
-
这里不是很清楚你想做什么...所以用户会去Sharepoint然后点击某个地方浏览他的本地文件夹选择一个文件,然后它会上传文件到共享点?如果这就是你想要实现的原因,那么你可能想看看这个:SharepointPlus createFile;您必须使用 [html5rocks.com/en/tutorials/file/dndfiles/](HTML5 File API) 或旧浏览器的 Flash 解决方案...如果这不是您想要做的,请再次解释:-)
-
嗨,我遇到了类似的问题,你是怎么过来的?
标签: sharepoint sharepoint-2013