[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

File Iteration

Posted on 2006-05-13
1
Medium Priority
?
355 Views
Last Modified: 2010-04-16
hi,

I need to Iterate through a Directory, from the Root down, Parse all Lvls. I cannot think of the iteration that would do this.

I can Iterate through files, but it is the code of making it go through all levels that is baffling me.

Thanks in advance

Andrew
0
Comment
Question by:REA_ANDREW
1 Comment
 
LVL 11

Accepted Solution

by:
Jase-Coder earned 2000 total points
ID: 16673786
you must write a recursive function, this is a function that calls itself

public void Find(string Directory)
{
       string [] Directories = Directory.GetDirectories( Directory );

try{
        foreach(string dir in Directories)
        {
                    Console.WriteLine(dir);

                     Find(dir)

         }
}
catch(UnauthorizedAccessException)
{
   Console.WriteLine("Cannot open dir");
}
}


pass the root directory to this function
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Loops Section Overview
Suggested Courses
Course of the Month20 days, 3 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question