recursive console search that lists all .doc files

  • Thread starter Thread starter RML
  • Start date Start date
R

RML

hi guys

i have searched all day and cannot find the code i am looking for. i am new
to c# so please bear with me ;)

i want to write a console app that simly lists in the console window, all
files on c: that end with .doc

i had a look at some recursive search code for mp3 files, but it didnt list
the files, just how many files there were in each directory.

can anyone point me to a nice piece of code?

cheers
 
RML said:
hi guys

i have searched all day and cannot find the code i am looking for. i am new
to c# so please bear with me ;)

i want to write a console app that simly lists in the console window, all
files on c: that end with .doc

i had a look at some recursive search code for mp3 files, but it didnt list
the files, just how many files there were in each directory.

can anyone point me to a nice piece of code?

cheers

Take a second look at that mp3 search routine:
at some point it has to have a list of (mp3) files.
This routine just returns the count, *you* should
print all names found.
(for printing to console, see Console.WriteLine)
 
Hi RML,

As Hans said, the mp3 search routine probably has some useful
information. Look for GetFiles and GetDirectories.

A basic algorithm for searching a directory and its subdirectories is:

string[] FindFiles(string path)
{
string[] files
foreach(subdirectory of path) // use Directory.GetDirectory
files += FindFiles(subdirectory)

// no more subdirectories, time to check current directory
files += Directory.GetFiles(path, "*.mp3");
return files;
}
 
Back
Top