0
我遇到問題,將圖片的Sharepoint文件集合保存到本地目錄。我對Sharepoint 2016非常新,我遇到了解決此問題的問題。好像當我運行這段代碼時,它會首先給我提供我的文件集合的第一個映像。但是,當我查看目標目錄時,映像是0字節(只是一個空文件)。它保持運行一段時間後會引發以下異常錯誤。檢索文件集合並將它們保存到本地目錄
Error:
Additional information: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
public static void ImageRetrival(DHG.OneDrive.Helpers.OneDriveHelper oneDrive, string user)
{
try
{
var wb = userContext.Web;
userContext.Load(wb);
var files = oneDrive.GetOneDriveFilesByFolderName(user);
var test = Microsoft.SharePoint.Client.File.OpenBinaryDirect(userContext, wb.ServerRelativeUrl);
FileStream fs = null;
if (files != null)
{
foreach (var file in files)
{
var fileName = file.Name.ToString();
string path = @"C:\Top-Level\" + fileName;
fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite);
test.Stream.CopyTo(fs);
}
}
}
catch (Exception e)
{
throw e;
}
}
看看@JonSkeets例如這看起來是在我看來,很多清潔http://stackoverflow.com/questions/5730863/how-to-use-stream-copyto- on-net-framework-3-5 – MethodMan
@方法男人,我得到它的工作是更合乎邏輯的序列,而不是代碼。請看看更正。 – EasyE