private void AddTreeNodesByFolder(List<TreeNode> treeNodes, string folderName)
{
string[] modFolders = Directory.GetDirectories(mModsDirectoryPath);
if (modFolders == null)
{
return;
}
// check all the mod folders
foreach (string modPath in modFolders)
{
string modName = System.IO.Path.GetFileName(modPath);
TreeNode modNode = new TreeNode(modName);
bool hasChildren = false;
string searchDirectoryPath = JsonHelper.NormalizeSystemPath(modPath) + folderName;
if (Directory.Exists(searchDirectoryPath))
{
// check all the folders
foreach (string folderPath in Directory.EnumerateDirectories(searchDirectoryPath))
{
hasChildren = true;
string rootFolderName = System.IO.Path.GetFileName(folderPath);
TreeNode root = new TreeNode(rootFolderName);
modNode.Nodes.Add(root); // Add effect folder node under mod name node
AppendTreeNodes(root, folderPath); // Append tree nodes from nested folders and files
root.ExpandAll(); // Expand the top level
}
}
if (hasChildren)
{
treeNodes.Add(modNode);
modNode.ExpandAll();
}
}
}