title: how to concatenate 2 wave files in Stream?
body: <p>I worked on this <a href="https://stackoverflow.com/a/6778791/4935756" title="answer">answer</a> for my problem.
  I want that 2 wave files that get of database with byte array type concatenate together and play then dispose it!</p>
  
  <p>this is my code:</p>
  
  <pre><code> public static void Play()
   {
       List&lt;byte[]&gt; audio = dal.SelectSound("خدمات", "احیاء");
  
       byte[] sound = new byte[audio[0].Length + audio[1].Length];
  
       Stream outputSound = Concatenate(sound, audio);
  
       try
       {
             WaveFileReader wavFileReader = new WaveFileReader(outputSound);
             var waveOut = new WaveOut(); // or WaveOutEvent()
             waveOut.Init(wavFileReader);
             waveOut.Play();
        }
        catch (Exception ex)
        {
             Logs.ErrorLogEntry(ex);
        }
  }
  
   public static Stream Concatenate(byte[] outputFile, List&lt;byte[]&gt; sourceFiles)
   {
          byte[] buffer = new byte[1024];
  
          Stream streamWriter = new MemoryStream(outputFile);
  
          try
          {
              foreach (byte[] sourceFile in sourceFiles)
              {
                  Stream streamReader = new MemoryStream(sourceFile);
  
                  using (WaveFileReader reader = new WaveFileReader(streamReader))
                  {
                      int read;
                      while ((read = reader.Read(buffer, 0, buffer.Length)) &gt; 0)
                      {
                          streamWriter.Write(buffer, 0, read);
                      }
                  }
              }
          }
  
          return streamWriter;
      }
  </code></pre>
  
  <p>but I get this error:</p>
  
  <blockquote>
    <p>Not a WAVE file - no RIFF header</p>
  </blockquote>
  
  <p>after execute this line:</p>
  
  <pre><code>WaveFileReader wavFileReader = new WaveFileReader(outputSound);
  </code></pre>
  
  <p>Thanks in advance.</p>