0

How to write IEnumerable<byte> to disk?

IEnumerable<byte> NewRIFF = riff.s_Chunk_ID.
                                Concat(riff.ui_Chunk_Size).
                                Concat(riff.s_Format);

IEnumerable<byte> NewFMT = fmt.s_Sub_Chunk_ID_1.
                                Concat(fmt.ui_Sub_Chunk_Size_ID_1).
                                Concat(fmt.us_Audio_Format).
                                Concat(fmt.us_Num_Channels).
                                Concat(fmt.ui_Sample_Rate).
                                Concat(fmt.ui_Byte_Rate).
                                Concat(fmt.us_Block_Align).
                                Concat(fmt.us_Bits_Per_Sample);

IEnumerable<byte> NewDATA = data.s_Sub_Chunk_ID_2.
                                Concat(data.i_Sub_Chunk_Size_2).
                                Concat(data.byar_Audio_PCM_data);

IEnumerable<byte> NewWaveFile = NewRIFF.Concat(NewFMT).Concat(NewDATA);
Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Alex David
  • 585
  • 1
  • 11
  • 32

1 Answers1

4

you can use File.WriteAllBytes more info and example: http://msdn.microsoft.com/en-us/library/system.io.file.writeallbytes.aspx

UPDATE:

according to the comment there is a full answer:

File.WriteAllBytes(@"YourFullPath", NewRIFF.ToArray());

and the same for NewFMT, NewDATA and NewWaveFile

eyossi
  • 4,230
  • 22
  • 20
  • 1
    To convert `IEnumerable` to an array (which is required for using `File.WriteAllBytes`), see [this Jon Skeet answer](http://stackoverflow.com/a/268699/107625). – Uwe Keim Jul 15 '12 at 12:52