How can i write and read using a BinaryWriter?
<p>I have this code wich is working when writing a binary file:</p>

<pre><code>using (BinaryWriter binWriter =
                                new BinaryWriter(File.Open(f.fileName, FileMode.Create)))
                            {
                                for (int i = 0; i &lt; f.histogramValueList.Count; i++)
                                {

                                    binWriter.Write(f.histogramValueList[(int)i]);



                                }
                                binWriter.Close();
                            }
</code></pre>

<p>And this code to read back from the DAT file on the hard disk:</p>

<pre><code>fileName = Options_DB.get_histogramFileDirectory();
            if (File.Exists(fileName))
            {
                BinaryReader binReader =
                    new BinaryReader(File.Open(fileName, FileMode.Open));
                try
                {
                    //byte[] testArray = new byte[3];
                    int pos = 0;
                    int length = (int)binReader.BaseStream.Length;

                    binReader.BaseStream.Seek(0, SeekOrigin.Begin);

                    while (pos &lt; length)
                    {
                        long[] l = new long[256];

                        for (int i = 0; i &lt; 256; i++)
                        {
                            if (pos &lt; length)
                                l[i] = binReader.ReadInt64();
                            else
                                break;

                            pos += sizeof(Int64);
                        }
                        list_of_histograms.Add(l);
                    }
                }

                catch
                {
                }
                finally
                {
                    binReader.Close();
                }
</code></pre>

<p>But what i want to do is to add to the Writing code to write to the file more three streams like this:</p>

<pre><code>binWriter.Write(f.histogramValueList[(int)i]);
binWriter.Write(f.histogramValueListR[(int)i]);
binWriter.Write(f.histogramValueListG[(int)i]);
binWriter.Write(f.histogramValueListB[(int)i]);
</code></pre>

<p>But the first thing is how can i write all this and make it in the file it self to be identify by a string or something so when im reading the file back i will be able to put each List to a new one ?</p>

<p>Second thing is how do i read back the file now so each List will be added to a new List ?
Now it's easy im writing one List reading and adding it to a List.
But now i added more three Lists so how can i do it ?</p>

<p>Thanks.</p>
