spawn2004 0 Newbie Poster

Hi , can you please help me with an advice. I have a problem with treeview. I want to show in a treeview folders but just some of them. I have several layers of folders. For example

Root
 |
  =subfolder 1
     | = subsubfolder1
             |
              =subsubsubFolder1
             |
              =subsubsubFolder2
     | = subsubfolder 2
             |
             =subsubsubfolder2

My problem is that in the last child there might be more than one folder (subsubsubfolder1,2,3..etc) and in this folders I have files. I want to have in my treeview only the folders that contain a specific file. I was trying to make an algorithm with recursion but the nodes need to be created and that doesn't work if I put some statements for checking. Also I find the files but some branches don't have the child because they don't have the file and they are created till some point.
So probably the recursion is not a good idea.
I have another idea : Will it be good if I create and container objects for every subfolder that contains the name of the subfolder and the folders inside filtered by my rules for the file and after that populate the tree with the data from this container ?

Can you please help me with an idea or tell me if that is a good idea ?
Thank you in advance for the help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.