title: Employee File Search
body: <p>I write a file and input the First Name, Last Name, Employee Id, Address and Zip Code then Save, Then if you go to search and input the zip code the file of the same zip code will show,but when I input the zip code the file will not show. i think my code is having a problem can you help me with this.</p>
  
  <pre><code>    public partial class Form1 : Form
      {
          public Form1()
          {
              InitializeComponent();
          }
  
          private void Form1_Load(object sender, EventArgs e)
          {
              pnlRead.Location = pnlWrite.Location;
              pnlSearch.Location = pnlWrite.Location;
              pnlWrite.BringToFront();
              System.IO.File.WriteAllText("Employee.txt", string.Empty);
          }
  
          private void writeToolStripMenuItem_Click_1(object sender, EventArgs e)
          {
              pnlWrite.BringToFront();
          }
  
          private void exitToolStripMenuItem_Click_1(object sender, EventArgs e)
          {
              this.Close();
          }
  
          private void btnSave_Click_1(object sender, EventArgs e)
          {
              string EmployeeData;
              listRead.Items.Clear();
  
              EmployeeData = txtFirstName.Text + "\n" + txtLastName.Text + "\n"
                  + txtID.Text + "\n" + txtAddress.Text + "\n" + txtZipCode.Text + "\n\n";
              File.AppendAllText("Employee.txt", EmployeeData);
              txtFirstName.Clear();
              txtLastName.Clear();
              txtID.Clear();
              txtAddress.Clear();
              txtZipCode.Clear();
              txtFirstName.Focus();
              listRead.Items.Clear();
  
          }
  
          private void readToolStripMenuItem_Click(object sender, EventArgs e)
          {
              pnlRead.BringToFront();
              try
              {
                  string[] EmployeeData = File.ReadAllLines("Employee.txt");
                  listRead.Items.AddRange(EmployeeData);
                  listRead.ClearSelected();    
              }
              catch
              {
                  MessageBox.Show("File or path not found or invalid.");
              }
          }
  
          private void searchToolStripMenuItem_Click(object sender, EventArgs e)
          {
              pnlSearch.BringToFront();
          }
  
          private void btnSearch_Click(object sender, EventArgs e)
          {
              pnlRead.BringToFront();
              listRead.Items.Clear();
  
              try
              {
                  string[] EmployeeData = File.ReadAllLines("Employee.txt");
                  for (int i = 0; i &lt; EmployeeData.Length; i += 2)
                  {
                      if (EmployeeData[i] == txtSearch.Text)
                      {
                          listRead.Items.Add(EmployeeData[i]);
                          listRead.Items.Add(EmployeeData[i + 1]);
                      }
                  }
              }
              catch
              {
                  MessageBox.Show("File or path not found or invalid.");
              } 
          }
      }
  }
  </code></pre>