I\'m trying to walk through a whole directory tree and print out all the file names on a listbox control. I wrote some code but there are errors. Not sure what I\'m doing wr
Use GetDirectories() overload accepting SearchOption:
string[] dirs = Directory.GetDirectories(path, "*", SearchOption.AllDirectories))
foreach(dir)
{
...
}
or better EnumerateFiles():
IEnumerable files = Directory.EnumerateFiles(path, "*.*", SearchOption.AllDirectories))
foreach(files)
{
...
}
Notice it performs lazy filesystem scan.