logo CodeStepByStep logo

Crawl

Language/Type: VB recursion file input

Write a recursive subroutine named Crawl that accepts a string for a file or directory name as a parameter and prints information about that file or directory. If the name represents a normal file, just print its name. If the name represents a directory, print its name and information about every file/directory inside it, indented by 4 spaces at each level. For example, the call of Crawl("course") might print the following information about your course directory:

course
    handouts
        lecture-schedule.xls
        syllabus.doc
    homework
        1-gameoflife
            GameOfLife.zip
            life.h
            life.vb

Show the files in a given directory sorted in alphabetical order. (You may want to use the Arrays.sort command to help you with this.)

Constraints: Your subroutine must be recursive, though you may use a loop to help you as appropriate.

Function: Write a VB function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.