public GetFiles ( string path, FileEventHandler handler, bool recursive ) : void | ||
path | string | The directory to get files. |
handler | FileEventHandler | The |
recursive | bool | if set to |
return | void |
public void GetFiles(string path, FileEventHandler handler, bool recursive)
{
foreach (string fileName in Directory.GetFiles(path))
{
bool cancel = false;
handler(fileName, ref cancel);
if (cancel)
{
return;
}
}
// Check subdirs
if (recursive)
{
foreach (string folderName in Directory.GetDirectories(path))
{
GetFiles(folderName, handler, recursive);
}
}
}