title: Reading multiple files in a Stream
body: <p>Hei!</p>
  
  <p>How can I read multiple text files at once? 
  What I want to do is read a series of files and append all of them to one big file. Curently I am doing this:</p>
  
  <ol>
  <li>take each file and open it with a StreamReader</li>
  <li>read the StreamReader completely in a StringBuilder and append it to the current StreamBuilder</li>
  <li>check if the memory size is exceeded and if yes write the StringBuilder at the end of the file and empty the StrigBuilder</li>
  </ol>
  
  <p>Unfortunately, I observed that the reading speed avg is only 4MB/sec. I noticed that when I move files around the disk I get a speed of 40 MB/sec. 
  I am thinking of buffering the files in a Stream and reading them all at once as I do with the writting. Any idea how can I achieve this?</p>
  
  <p>Update:</p>
  
  <pre><code> foreach (string file in System.IO.Directory.GetFiles(InputPath))
          {
              using (StreamReader sr = new StreamReader(file))
              {
  
                  try
                  {
                      txt = txt+(file + "|" + sr.ReadToEnd());
                  }
                  catch // out of memory exception 
                  {
                      WriteString(outputPath + "\\" + textBox3.Text, ref txt);
                      //sb = new StringBuilder(file + "|" + sr.ReadToEnd());
                      txt = file + "|" + sr.ReadToEnd();
                  }
  
              }
  
              Application.DoEvents();
          }
  </code></pre>
  
  <p>This is how I'm doing it now. </p>