title: Outputting all text file titles to a textbox on Windows Form
body: <p>Getting a bit stuck on a piece of code I'm trying to write and was hoping for a helping hand if anyone knows where I'm going wrong!</p>
  
  <p>I have a simple Windows Form where I have a folder browser. The user will browse to a folder and any sub-folders within will then be searched for a text file that has the word "Passed" in the title (not the body of the text file itself). There will be files with "Passed" in from many different folders, and I want the functionality of the app to search through all sub-folders and return the all the files that have this in their name.</p>
  
  <p>At present I have the following code:</p>
  
  <pre><code>    private void searchButton_Click(object sender, EventArgs e)
      {
          if (textBox1.Text == "")
          {
              MessageBox.Show("Please enter a path");
          }
          else
          {
              string[] allFiles = Directory.GetFiles(textBox1.Text, "*Passed*.*", SearchOption.AllDirectories);
              string name = resultsText.Text;
              foreach(string file in allFiles)
              {
                  if (file.Contains("Passed"))
                  {
                      resultsText.Text = file;
                  }
              }
         }
      }
  </code></pre>
  
  <p>However, in the resultsText texbox, it only returns 1 value. There are multiple files with "Passed" in their title and I would like to print them all to this textbox. Does anyone know where I may be going wrong and why I am only getting one file rather than all of them?</p>
  
  <p>Also, this method seems to return the whole file path e.g.)
  C:\Program Files\Test\abc\PassedTests.txt - does anyone know how I can trim the full path so it just returns the file name and extension?</p>
  
  <p>Any help is greatly appreciated!</p>