Title: Community Server 2007: Correct sorting of Files TreeView
Slug: community-server-2007-correct-sorting-of-files-treeview
Date: 2009-01-28 12:16:00
Author: Kartones
Lang: en
Tags: Kartones.Net, C#, ASP.NET, Development, .NET
Description: A guide on sorting files in Community Server 2007's treeview by name instead of creation date, with simple code changes.

 <p>Something that has annoyed me since I started using Community Server was that the Files treeview didn't sort by name, but by internal Ids (so the actual sort order is "by creation date").</p>  <p>So, now that I'm deeping in how CS works internally, I decided to fix it by sorting alphabetically both the folder groups and folders for the Downloads section.</p>  <p>It requires modification of a core component (<i>CommunityServerFiles20</i> project, CommunityServer.Files assembly), but the change is just changing two lines of code!</p>  <ol>   <li>Open the <span style="color: #2b91af">Folders </span>class       <br></li>    <li>Find the GetFoldersByGroupID  method      <br></li>    <li>Find this comment:      <br><span style="color: green">// Sort the galleries        <br></span><a href="http://11011.net/software/vspaste"></a></li>    <li>Change the line following the comment to:      <br>folders.Sort(<span style="color: blue">new</span><span style="color: #2b91af">SectionSorter</span>(<span style="color: #2b91af">SectionSortBy</span>.Name));       <br><a href="http://11011.net/software/vspaste"></a></li>    <li>Find the GetFolderGroups() method      <br></li>    <li>Find this comment:      <br><span style="color: green">// Sort the forum groups        <br></span><a href="http://11011.net/software/vspaste"></a></li>    <li>Change the line following the comment to:      <br>folderGroups.Sort(<span style="color: blue">new</span><span style="color: #2b91af">GroupSorter</span>(<span style="color: #2b91af">GroupSortBy</span>.Name)); <a href="http://11011.net/software/vspaste"></a></li> </ol>  <p>Rebuild in release mode, replace the assembly in \bin folder, and we're done!</p>  <p><img src="https://images.kartones.net/posts/kartonesblog/kartonesnet_sortedtreeview.jpg"></p>  <p>As an added bonus, on the Control Panel's file management the folder groups &amp; files will be sorted too!</p>