By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,156 Members | 989 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,156 IT Pros & Developers. It's quick & easy.

Parsing a directory

P: n/a
I'm trying to parse a directory, but am not sure of the best way of
doing it. Preferably using only .net instructions. Can anyone give me an
idea of how to do this?

Thanks in advance for any help that anyone can give me...

John
Nov 15 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
What do you mean "parsing a directory"? Do you mean parsing a directory
path, or enumerating the files in a directory?

Well, the Path class will help parsing the path. The Directory and
DirectoryInfo will help enumerate the files.

"John Young" <polomint77_ATATATATAT_hotmail.com> wrote in message
news:uU**************@TK2MSFTNGP09.phx.gbl...
I'm trying to parse a directory, but am not sure of the best way of
doing it. Preferably using only .net instructions. Can anyone give me an
idea of how to do this?

Thanks in advance for any help that anyone can give me...

John

Nov 15 '05 #2

P: n/a
using System.IO;

Write a separate method (so it can be used recursively), and pass it a
parameter that represents the directory where you want things to start.

In that method, create a DirectoryInfo object, passing the directory's path
in the ctor. That object will have its own collection of DirectoryInfo
objects called Directories, and its own collection of FileInfo objects
called Files.

Typically, you would do what you want to do for each FileInfo in Files, and
for each DirectoryInfo in Directories, call the method recursively. That
way, you can process all the files and directories in a subtree of arbitrary
depth. The order in which you do these things will determine whether you do
a depth-first or breadth-first traversal of the directory tree.

"John Young" <polomint77_ATATATATAT_hotmail.com> wrote in message
news:uU**************@TK2MSFTNGP09.phx.gbl...
I'm trying to parse a directory, but am not sure of the best way of
doing it. Preferably using only .net instructions. Can anyone give me an
idea of how to do this?

Thanks in advance for any help that anyone can give me...

John

Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.