Formally, what you need is a n-ary tree. Nesting dictionaries would be messy and unnecessary, in c# you can do something like the following
public class DirectoryThing
{
public Whatever PropertyOfDirectoryIWantToKeep {get; set;}
public List<subdirectorythings> {get; private set}
}</subdirectorythings>
With proper naming :) etc and the addition of any methods/indexers you want to get infotmation in/out. It should be pretty easy to write a converter to work with the .net framework's
DirectoryInfo
class. In some circumstances you might even just want to use the
DirectoryInfo
type. For example if you are just counting subdirectories you can instantiate the root directory's
DirectoryInfo
class, use its
GetDirectories[
^] method to get the children and recursively traverse the whole tree, keeping a running total of the number of subdirectories until the tree is traversed.