q; read file names

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
I need to read all the files in current and sub folders and put it into a
list box, is there any example in C# I can use?
 
First set up a ReadDirectory() method that takes a file path. In the method,
iterate through all files and add to an array (List<string> or List(Of
String) in VB) is a good option for .NET 2.0. Add each file name you find.
Actually, you might want to use a generic directory with the filename and
path so you can actually do something with the files.

When you find directories in the ReadDirectory() routine, call it again for
the new directory. This will get all files.

All you need is the DirectoryInfo() class and possibly a FileInfo() class.

How do I sample from the Quickstarts:
http://samples.gotdotnet.com/quickstart/howto/

Look for:

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think outside of the box!
*************************************************
 
Missed the rest: Look for How Do I...Enumerate directories and their
contents?

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think outside of the box!
*************************************************
 
Back
Top