Logo

Microsoft.SharePoint.Client 读取SharePoint 文件

photo

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/这一段路径  ,要注意前面的/ 不能少. 这个路径可以通过 在线查看  选择在桌面应用打开. 然后再找到下图的位置复制出来(注意 不需要最后的参数)

 

橙子主题打折出售

其实我不卖,主要是这里是放广告的,所以就放了一个
毕竟主题都没做完,卖了也是坑.

购买它
本文为原创文章,请注意保留出处!

热门文章

C#图片处理 通常对一幅图片的处理包括:格式变换,缩放(Scale),翻转(Rotate),截取(Clip),滤镜...C#图片处理 作者:Pastore Antonio
1715 浏览量
memcached 处理 多端口:https://blog.csdn.net/Erica_1230/article/deta...memcached处理 作者:Pastore Antonio
1673 浏览量
AssemblyInstaller 的应用 usingSystem;usingSystem.Configuration.Install;us...AssemblyInstaller的应用 作者:Pastore Antonio
1665 浏览量
WordPress上传文件大小限制修改 WordPress上传媒体文件默认大小限制是2M或8M,当文件大于这个限定大小时,是上传不了的。其实...WordPress上传文件大小限制修改 作者:Pastore Antonio
1639 浏览量
Layui开发日记 丰富版table:https://saodiyang.gitee.io/layui-soul-ta...Layui开发日记 作者:Pastore Antonio
1591 浏览量