我有一个元组列表,我正在用一个文件夹的所有目录填充这个列表,并使用以下代码将它绑定到 asp:ListView:
List<string> directoryContent = new List<string>(Directory.GetFileSystemEntries(dirPath);
List<Tuple<string, string>> directoryList = new List<Tuple<string, string>>();
for (int i = 0; i < directoryContent.Count; i++)
{
FileAttributes attr = File.GetAttributes(directoryContent[i]);
if (attr.ToString().Equals("Directory"))
{
String str = directoryContent[i].Remove(0, dirPath.Length);
string count = Directory.GetFiles(directoryContent[i], "*.*", SearchOption.AllDirectories).Length.ToString();
directoryList.Add(new Tuple<string, string>(str, count));
}
}
directoryListView.DataSource = directoryList;
directoryListView.DataBind();
例如找到的目录是
12
566
10001
10
模板
文件
以这种方式对 List 或 ListView 进行排序的最佳方法是什么?先感谢您。我需要对它们按以下顺序排序的目录进行排序:
文件
模板
10
12
566
1001
临摹微笑
相关分类