Howdy all, Great to see the community up an running still. I'm just Hoping you guys/gals could help me again with something. Thanks in advance..

Ok Sit rep.

Need to be able to scan through all files in Given folder and list them with out tree in plain list box... and count each sub etc...

Currently using this method:-

void GetDirectorySubs(string PassDir, FileInfo ThisFile)
        {
            DirectoryInfo DirClass = new DirectoryInfo(PassDir);
            DirectoryInfo[] CurrDir = DirClass.GetDirectories();

            foreach(DirectoryInfo C_Direc in DirClass.GetDirectories())
            {
                Newfiles_lb.Items.Add(C_Direc.Name);
                   foreach(FileInfo C_files in DirClass.GetFiles())
                   {
                       Newfiles_lb.Items.Add( C_files.DirectoryName+" "+C_files.Name + @"\");

                      //if (DirClass.GetDirectories().Count() > 1)  GetDirectorySubs(C_files.DirectoryName, null);
                   }
            
            }

Now the Problem I have is that i have say this Strut on disc:

#1 folder\
#2 Folder\
#3 Folder\
etc.....

But each time i use the foreach dir in this dir command i only get the sub folder not all below..

I don't need a super routine....Just a simple loop while Directory.count less is Zero type solution...

My brains not being logical.....this month...It's manual writing month...ha ha
:confused:

Recommended Answers

All 3 Replies

Yes, you then have to call the subroutine on each of the new folders you find.

Thanks anywas..I worked it out..Cheers For you fast response...

Anyone with the same problem, the recursive scanning article shows how to do it exactly.

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.