Logo
技术 C#

Microsoft.SharePoint.Client 读取SharePoint 文件

photo
Pastore Antonio

2022年06月01日

https://blog.darkthread.net/blog/access-sharepoint-doclib-with-dotnet/ 可参考它的方法.代码是通用的(它里面包括了文件夹操作等)

我安装的包如下:

 

 读取文件:

   

var ctx = new ClientContext(url);

// Provide credentials
// (Might be able to skip this if the server is on prem and your
// AD user has permissions to access the library)
var password = new SecureString();
foreach (var c in “Sharepoint密码”.ToCharArray())
{
password.AppendChar(c);
}

ctx.Credentials =
new SharePointOnlineCredentials(“Sharepoint账号”, password);

var t= Microsoft.SharePoint.Client.File.OpenBinaryDirect(ctx, “/这一段路径 “);

MemoryStream ms = new MemoryStream();
t.Stream.CopyTo(ms);

 

–注意这里出来的t里的流是不能直接操作的.这里传的路径 是除了https://xxxx.sharepoint.com/这一段路径  ,要注意前面的/ 不能少. 这个路径可以通过 在线查看  选择在桌面应用打开. 然后再找到下图的位置复制出来(注意 不需要最后的参数)

 

本文为原创文章,请注意保留出处!
修复群晖Synology Drive client右键菜单缺失问题 Local, clean & environmental 作者:Pastore Antonio
1806 浏览量
1780 浏览量
configure: error: Package requirements (oniguruma) were not met Local, clean & environmental 作者:Pastore Antonio
1525 浏览量
Adobe Acrobat Pro 激活 Local, clean & environmental 作者:Pastore Antonio
1520 浏览量
追寻日出,找回自己 Local, clean & environmental 作者:Pastore Antonio
1489 浏览量