Now I'm having a problem of populating some sub lists. I have a main list called "list" of type FileInfo with thousands of files. What I want to do is to split this main list into several sub lists, each of which contains a pack of files with the same name. I did sth like this:
var File = list;
string[] foldername = Names.Distinct().ToArray();
List<TreeNode> N1 = new List<TreeNode>();
List<FileInfo>[] sublist = new List<FileInfo>[foldername.Length];
for (int j = 0; j < foldername.Length; j++)
{
N1.Add(clicked.Nodes.Add(foldername[j]));
foreach (FileInfo file in File)
{
if (file.Name== N1[j].Name)
sublist[j].Add(file);
}
}
For example the foldername array has 7 elements, so I want to have 7 sublists. Files included in each sublist have the same name with the tree node N1[j]. The result, however, is that the
sublist[j].Add(file)
isn't excuted at all, and every sublist is null. I have no idea what's wrong. Anybody got any idea? Thank you