Q:

How to add files recursively to a listbox by selecting a dir in C#

I'm trying to add a list of files to a listbox which follows all sub-directories 
Currently I am using the following code however it only searches one directory and does not recurse into subdirectories. 
  FolderBrowserDialog odd = new FolderBrowserDialog();
  private void button2_Click(object sender, EventArgs e)
  {
      if (odd.ShowDialog() == DialogResult.OK)
      {

          string folderName = odd.SelectedPath;
          foreach (string f in Directory.GetFiles(folderName))
              checkedListBox1.Items.Add(f);
      }
  }

Now I modified to this, but says string f doesn't exist in the current code
foreach (string f in Directory.GetFiles(folderName, "*.*", SearchOption.AllDirectories));
checkedListBox1.Items.Add(f);

A:

You could use 
string[] filePaths = Directory.GetFiles(@"C:\CurrentDirectoryName", "*.*", SearchOption.AllDirectories);

Then bind the listbox to that string array

