title: How to get a richTextBox to read listbox
body: <p>what i'm trying to do is this i have a <code>listBox</code> that shows all .txt files in a folder but I want to be able to click a .txt in the <code>listBox</code> and have my <code>richTextBox</code> show the text from that .txt file.
  Code to show files:</p>
  
  <pre><code>    private void Scripts_Load(object sender, EventArgs e)
      {
          DirectoryInfo dinfo = new DirectoryInfo(@"scripts");
          FileInfo[] Files = dinfo.GetFiles("*.txt");
          foreach (FileInfo file in Files)
  
              list.Items.Add(file.Name);
      }
  </code></pre>
  
  <p>As for the code to show in <code>textBox</code> I have tried many internet answers and got nowhere main errors being <code>Argument 1: cannot convert from 'object' to 'string'</code> 
  The closest I have got is with this</p>
  
  <pre><code>    //Get the FileInfo from the ListBox Selected Item
  FileInfo SelectedFileInfo = (FileInfo) listBox.SelectedItem;  
  
  //Open a stream to read the file  
  StreamReader FileRead = new StreamReader(SelectedFileInfo.FullName);
  
  //Read the file to a string
  string FileBuffer = FileRead.ReadToEnd();
  
  //set the rich text boxes text to be the file
  richTextBox.Text = FileBuffer;
  
  //Close the stream so the file becomes free!
  FileRead.Close();
  </code></pre>
  
  <p>It Crashes saying: `System.InvalidCastException: 'Unable to cast object of type 'System.String' to type 'System.IO.FileInfo'.'</p>
  
  <p>There was already a comment saying that this happens and the guy replied saying change line 1 to FileInfo SelectedFileInfo = new FileInfo(listBox1.SelectedItem); this failed saying<code>Argument 1: cannot convert from 'object' to 'string'</code> 
  `</p>
  
  <p>I did it YAY!!! </p>
  
  <pre><code>        private async void listBox1_SelectedIndexChanged(object sender, EventArgs e)
      {
          string value1 = list.SelectedItem.ToString();
          richTextBox1.Text = value1;
          using (StreamReader sr = new StreamReader("scripts\\" + value1))
          {
              {
                  String line = await sr.ReadToEndAsync();
                  richTextBox1.Text = line;
              }
          }
      }
  </code></pre>