title: how to limit number of uploads in multi-select OpenFileDialog in C#
body: <p>How can I limit the number of files to be uploaded using the multi-select <code>openfiledialog</code> in c#?</p>
  
  <p>Here's my code:</p>
  
  <pre><code>private void btn_upload_Click(object sender, EventArgs e)
  {
      OpenFileDialog op1 = new OpenFileDialog();
      op1.Multiselect = true;
      op1.ShowDialog();
      op1.Filter = "allfiles|*.xls";
      textBox1.Text = op1.FileName;
      int count = 0;
      string[] FName;
      foreach (string s in op1.FileNames)
      {
          FName = s.Split('\\');
          File.Copy(s, "C:\\file\\" + FName[FName.Length - 1]);
          count++;
      }
      MessageBox.Show(Convert.ToString(count) + " File(s) copied");
   }
  </code></pre>
  
  <p>It will upload as how much the user wants to. But I want to limit it by 5 files only.</p>