求助,这个代码怎么改

[复制链接]
查看11 | 回复3 | 2021-1-27 05:27:06 | 显示全部楼层 |阅读模式
因为现实需要,我们把在sharepoint上的文件同步到本地,
然后用本地app软件连接sharepoint网站对该文件进行文件签出,然后更新文件内容,再进行文件签入。
实验账户是有签入签出权限的。
本站https://mycompany.com/teams/Shanghai
但是会自动进入https://mycompany.com/teams/Shanghai/SitePages/Summary.aspx
所有目标文件都在https://mycompany.com/teams/Shanghai/_layouts/15/viewlsts.aspx页面Documents下,
点击进入https://mycompany.com/teams/Shanghai/Documents/Forms/AllItems.aspx可看到文件列表。
代码如下:
C#code
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
usingMicrosoft.SharePoint;
......
using(Microsoft.SharePoint.Client.ClientContextclient=newMicrosoft.SharePoint.Client.ClientContext("https://bbs.76seo.commycompany.com/teams/Shanghai"))
{
client.Credentials=www.76seo.comnewNetworkCredential("myAlias","myPW","myArear");
varlist=client.Web.Lists.GetByTitle("Documents");
//client.ExecuteQuery();//如果运行本句,就会出现403forbidden错误。
foreach(varfileinlist.RootFolder.Files)//出现错误"Thecollectionhasnotbeeninitialized.Ithasnotbeenrequestedortherequesthasnotbeenexecuted.Itmayneedtobeexplicitlyrequested."
{
Console.WriteLine(file.Name);
}
varfindFile=list.RootFolder.Files.GetByUrl(fileName);//fileName是文件名,“a.txt”这样。
findFile.CheckOut();
client.Load(findFile);
client.ExecuteQuery();
RefreshExcel();//刷新文件内容
findFile.CheckIn("Updated",Microsoft.SharePoint.Client.CheckinType.OverwriteCheckIn);
client.Load(findFile);
client.ExecuteQuery();
}
分 -->
回复

使用道具 举报

千问 | 2021-1-27 05:27:06 | 显示全部楼层
这个问题好像与WinCE没有关系,是PC上的功能吧?
回复

使用道具 举报

千问 | 2021-1-27 05:27:06 | 显示全部楼层
可能是没有权限吧

————————————————————————————————————————————————
我参加CSDN博客了,投票网址如下,大家多多支持。多谢先!
http://vote.blog.csdn.net/blogstar2014/details?username=91program#content
回复

使用道具 举报

千问 | 2021-1-27 05:27:06 | 显示全部楼层
可能是没有权限吧

————————————————————————————————————————————————
我参加CSDN博客了,投票网址如下,大家多多支持。多谢先!
http://vote.blog.csdn.net/blogstar2014/details?username=91program#content
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行