File Iteration

Posted on 2006-05-13
Last Modified: 2010-04-16

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

Question by:REA_ANDREW
    1 Comment
    LVL 11

    Accepted Solution

    you must write a recursive function, this is a function that calls itself

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

            foreach(string dir in Directories)


       Console.WriteLine("Cannot open dir");

    pass the root directory to this function

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Article by: Ivo
    Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
    Article by: Najam
    Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now