I was wondering if anyone knows of a cleaner way to do this. I have a section of my program that will list all input directories that contain files. 

However, to do this I manually store each input directory as a variable and use these as targets for the search.

I was wondering if there is a cleaner way to do this?

For example, the pseudo code I have in my head at the moment is:

* Starting at directory `Date`, `If FolderName == "Input"` then store all subfolders in array `InputSubs`
* For each folder in `InputSubs`, if no subfolder is contained within `InputSub` and no files are contained in `InputSubs` then move on to next
* If `InputSubs` contains a subdir, then store all subdirs in array `InputSubs2` and move on to next
* If `InputSubs` contains files, store `DirPath` and `FileName` as string in array `InputFiles`
* Repeat `InputSubs` process for `InputSubs2`

The deepest an input folder goes is 2 directories.

An example of the input folder structure is in the attached image.

[![enter image description here](https://i.stack.imgur.com/jyOZt.jpg)](https://i.stack.imgur.com/jyOZt.jpg)

An example of the code I currently use is as follows.

```
ListBox1.Items.Clear();

if (Directory.GetFiles(SalesInputFilePath + ResourceDetails.InputFolders(FormDMM, EH, ObjApp, Modules, "AustraliaFolder")).Length != 0) 
{ 
     ListBox1.Items.Add(Directory.GetFiles(SalesInputFilePath + ResourceDetails.InputFolders(FormDMM, EH, ObjApp, Modules, "AustraliaFolder"))[0]); 
}

if (Directory.GetFiles(SalesInputFilePath + ResourceDetails.InputFolders(FormDMM, EH, ObjApp, Modules, "DE1Folder")).Length != 0) 
{
    ListBox1.Items.Add(Directory.GetFiles(SalesInputFilePath + ResourceDetails.InputFolders(FormDMM, EH, ObjApp, Modules, "DE1Folder"))[0]); 
}

if (Directory.GetFiles(SalesInputFilePath + ResourceDetails.InputFolders(FormDMM, EH, ObjApp, Modules, "PL1Folder")).Length != 0) 
{ 
    ListBox1.Items.Add(Directory.GetFiles(SalesInputFilePath + ResourceDetails.InputFolders(FormDMM, EH, ObjApp, Modules, "PL1Folder"))[0]); 
}

if (Directory.GetFiles(SalesInputFilePath + ResourceDetails.InputFolders(FormDMM, EH, ObjApp, Modules, "EuropeFolder")).Length != 0) 
{ 
    ListBox1.Items.Add(Directory.GetFiles(SalesInputFilePath + ResourceDetails.InputFolders(FormDMM, EH, ObjApp, Modules, "EuropeFolder"))[0]); 
}

if (Directory.GetFiles(SalesInputFilePath + ResourceDetails.InputFolders(FormDMM, EH, ObjApp, Modules, "fr1Folder")).Length != 0) 
{ 
    ListBox1.Items.Add(Directory.GetFiles(SalesInputFilePath + ResourceDetails.InputFolders(FormDMM, EH, ObjApp, Modules, "fr1Folder"))[0]); 
}

if (Directory.GetFiles(SalesInputFilePath + ResourceDetails.InputFolders(FormDMM, EH, ObjApp, Modules, "FranceFolder")).Length != 0) 
{ 
    ListBox1.Items.Add(Directory.GetFiles(SalesInputFilePath + ResourceDetails.InputFolders(FormDMM, EH, ObjApp, Modules, "FranceFolder"))[0]); 
}

if (Directory.GetFiles(SalesInputFilePath + ResourceDetails.InputFolders(FormDMM, EH, ObjApp, Modules, "HKFolder")).Length != 0) 
{ 
    ListBox1.Items.Add(Directory.GetFiles(SalesInputFilePath + ResourceDetails.InputFolders(FormDMM, EH, ObjApp, Modules, "HKFolder"))[0]); 
}

if (Directory.GetFiles(SalesInputFilePath + ResourceDetails.InputFolders(FormDMM, EH, ObjApp, Modules, "UKFolder")).Length != 0) 
{ 
    ListBox1.Items.Add(Directory.GetFiles(SalesInputFilePath + ResourceDetails.InputFolders(FormDMM, EH, ObjApp, Modules, "UKFolder"))[0]); 
}

```

I have an inescapable tendency to over complicate things and was wondering if there was an easier, or at least more efficient way to do it than the pseudo code from my head. 

Thank you.