對於下面的CilentContext代碼來在客戶機中下載文檔。當代碼擊中OpenBinaryDirect()方法時,我得到未經授權的401錯誤。下載文件時出現401錯誤 - SharePoint ClientContext
using (SPSite site = new SPSite(SPContext.Current.Web.Url, SPUserToken.SystemAccount))
{
using (FileInformation sharePointFile = Microsoft.SharePoint.Client.File.OpenBinaryDirect(clientContext, serverRelativeUrlOfFile))
{
using (Stream destFile = System.IO.File.OpenWrite(fileDestinationPath))
{
byte[] buffer = new byte[8 * 1024];
int byteReadInLastRead;
while ((byteReadInLastRead = sharePointFile.Stream.Read(buffer, 0, buffer.Length)) > 0)
{
destFile.Write(buffer, 0, byteReadInLastRead);
}
}
}
}
爲什麼會出現此錯誤的任何原因?