title: Index was outside the bounds of the array
body: <p>I get an "Index was outside the bounds of the array" error with the below code. It occurs after the music stops and I try to click another song. How do I solve this issue?</p>
  
  <pre class="lang-cs prettyprint-override"><code>private void button1_Click(object sender, EventArgs e)
  {
      if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
      {
          files = openFileDialog1.SafeFileNames;
          paths = openFileDialog1.FileNames;
          for (int i = 0; i &lt; files.Length; i++)
          {
              listBox1.Items.Add(files[i]);
          }
      }
  }
  
  private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
  {
      axWindowsMediaPlayer1.URL = paths[listBox1.SelectedIndex];
  }
  </code></pre>