本文介绍了在VB中对FolderCollections进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个SharePoint文件夹列表,需要按名称对它们进行排序,而不需要循环播放。 可以这样做吗? 每次都死路一条。
I have a list of SharePoint folders and need to sort them by name without looping thru. Can this be done? Have hit a dead end every time.
推荐答案
您可以使用Lamba Expression按文件夹名称对文件夹集合进行排序:
You could use Lamba Expression to order folder collection by folder name:
string siteUrl = "http://sp/sites/dev/";
ClientContext clientContext = new ClientContext(siteUrl);
Web site = clientContext.Web;
FolderCollection collFolder = site.Folders;
clientContext.Load(collFolder, folders => folders.OrderByDescending(folder => folder.Name));
clientContext.ExecuteQuery();
foreach (var item in collFolder)
{
Console.WriteLine(item.Name);
}
以上是使用C#代码,你可以根据你的逻辑转换为VB。
The above is using C# code and you could convert to VB based on your logic.
谢谢
最好的问候
这篇关于在VB中对FolderCollections进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!