Index out of bounds array exception +Streamreader
<p>I have encountered an array index out of bounds exception based on the following codes:</p>

<p>I understand that readtoend method may disrupt the pointer for the streamreader, hence i implement the discardbuffereddata and seekorigin 0. However, im still getting an index out of bounds. help please? thanks!</p>

<pre><code>StreamReader sr = new StreamReader(@".\Input\" + inServer + ".txt");
        readall = sr.ReadToEnd();
        string[] splited = Regex.Split(readall, "~~~~~~~~~~~~~~");
        sr.BaseStream.Seek(0, SeekOrigin.Begin);
        sr.DiscardBufferedData();


    while (sr.Peek() &gt;= 0)
            {
                currLine = sr.ReadLine();
}
</code></pre>
