We developed a web part showing the folders hierarchy using tree view control. However the folders were not getting displayed in the tree view node in the order they are visible inside the document library i.e. sorted on name.
Creating a tree view
So finally used the following code to sort the folders
List<SPFolder> folderList = new List<SPFolder>();
foreach (SPFolder myFolder in folder.SubFolders){
folderList.Add(myFolder);
}
folderList.Sort(delegate(SPFolder p1, SPFolder p2) { return p1.Name.CompareTo(p2.Name); });
For more information on sorting
http://www.developerfusion.com/code/5513/sorting-and-searching-using-c-lists/
Bye..
Thanks! I had the exact same issue……
LikeLike
many many thanks. TreeView control in web forms does not have a Sort function and using this I am able to sort the folders before adding to tree
LikeLike