q; read file names

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?
 
C

Cowboy \(Gregory A. Beamer\)

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!
*************************************************
 
C

Cowboy \(Gregory A. Beamer\)

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!
*************************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top