我一直在创建一个提供商托管的应用程序,但我一直在使用 CSOM C# 检索文档标题,我的代码如下。
var spContext = SharePointContextProvider.Current.GetSharePointContext(Context);
using (var clientContext = spContext.CreateUserClientContextForSPHost())
{
Web web = clientContext.Web;
ClientOM.List list = clientContext.Web.Lists.GetByTitle("Documents");
clientContext.Load(list);
clientContext.ExecuteQuery();
Response.Write(list.Title);
Folder folder = list.RootFolder;
clientContext.Load(folder);
clientContext.ExecuteQuery();
string count = folder.ItemCount.ToString();
Response.Write("Folder variable count: "+count);
ClientOM.FileCollection fcollection = folder.Files;
clientContext.Load(folder.Files);
clientContext.ExecuteQuery();
Response.Write("\n Files count: " + folder.Files.Count);
foreach (ClientOM.File f in folder.Files)
{
Response.Write(f.Title);
}
}
输出:文件夹变量计数:6 文件计数:0