title: Progress bar and file loading
body: <p>I have a large <code>text file</code> containing lots of lines of data. In my application I open this file, read each line by matching a regular expression and display it in a Datagridview. The total number of rows generated are around 2000(<em>Sometimes even more, so pretty huge</em>). </p>
  
  <p>So for all this operations it takes fairly large amount of time. So I moved this code into another thread using background worker and everything is fine except that I want to show the loading status in a progress bar where I am failing.</p>
  
  <p>I have used <code>FileInfo</code> class to get the file length and then gave this value to the <code>Progressbar.Maximum</code>. Seems not the right approach because a test file containing "3" lines returned a file length of "305". I donot understand how much step interval I should be giving this way.</p>
  
  <p>Code sample:</p>
  
  <pre><code>FileInfo ff = new FileInfo(openFileDialog1.FileName);
  int fsize= Convert.ToInt32(ff.Length);
  int val=1;
  pgbar_load.Invoke(new MethodInvoker(delegate { pgbar_load.Maximum = fsize; }));
  </code></pre>
  
  <p>and in the loop:  </p>
  
  <pre><code>++val;
  wk.ReportProgress(val);
  </code></pre>
  
  <p>and then:</p>
  
  <pre><code>private void bgwrkr_load_ProgressChanged(object sender, ProgressChangedEventArgs e)
  {
     pgbar_load.Value = e.ProgressPercentage;
  }
  </code></pre>
  
  <p>So two things I am looking for:  </p>
  
  <ol>
  <li>Setting the maximum value for the progress bar.  </li>
  <li>Setting the step index correctly. </li>
  </ol>
  
  <p>Please suggest me a way to move forward.</p>