I am trying to read the contents of a file as a stream in a document library on a sharepoint website. I use AppOnlyAccessToken
. The source code works until today. And I have no idea about this problem. My source code:
string realm = TokenHelper.GetRealmFromTargetUrl(SiteUrl);
var token = TokenHelper.GetAppOnlyAccessToken(TokenHelper.SharePointPrincipal, SiteUrl.Authority, realm);
var context = TokenHelper.GetClientContextWithAccessToken(SiteUrl.ToString(), token.AccessToken);
Stream stream = null;
var list = context.Web.GetList("/sites/mysites/mydoclib");
var document = list.GetItemById(fileId);
context.Load(document.File);
context.ExecuteQuery();
var streamX = document.File.OpenBinaryStream();
context.ExecuteQuery();
stream = streamX.Value;
return stream;
Error when ExecuteQuery()
receiving BinaryStream
. Error message:
The label applied to this element does not allow editing or deleting it. See item label for more details.
It works with a txt file and gets an error with the csv and excel file (xlsx).
source
share