Read the file in the document library: "Label applied to this element ..." C #

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);

//Initial
Stream stream = null;

var list = context.Web.GetList("/sites/mysites/mydoclib");

var document = list.GetItemById(fileId);
context.Load(document.File);
context.ExecuteQuery();

////Read File and return stream content of file
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).

+4
source share
2 answers

- , , , Microsoft , 24 , -.

, O365 (SRX617110692037176ID), , , . , .

Microsoft , , , .

, MS , , , , :

, , ,

+1

Source: https://habr.com/ru/post/1688798/


All Articles