Stream Help Needed
Publicado: 02 May 2014 16:59
Hello guys,
What can I be doing wrong ?
I get error : Object reference not set to an instance of an object.
this line : string[] parts = value.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
What can I be doing wrong ?
I get error : Object reference not set to an instance of an object.
this line : string[] parts = value.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
Código: Seleccionar todo
private void button2_Click(object sender, EventArgs e)
{
openFileDialog1.Filter = "Text File|*.txt";
openFileDialog1.FileName = String.Empty;
DialogResult result = openFileDialog1.ShowDialog();
if (result == DialogResult.OK)
{
Stream fs = openFileDialog1.OpenFile();
StreamReader reader = new StreamReader(fs);
while (reader.Peek() >= 0)
{
// textBox2.Text += "\n" + reader.ReadLine();
int pos = reader.ReadLine().IndexOf("-");
if (pos != -1)
{
string value = reader.ReadLine();
char[] delimiters = new char[] { '-' };
string[] parts = value.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
if (IsBase64Encoded(parts[1]))
{
string satir = Base64Decode(parts[1]);
textBox2.Text += "\n" + parts[0] + "-" + satir + "\r\n";
}
else
textBox3.Text += "\n" + reader.ReadLine() + "\r\n";
}
else
{
if (IsBase64Encoded(reader.ReadLine()))
{
string satir = Base64Decode(reader.ReadLine());
textBox2.Text += satir + "\r\n";
}
else
textBox3.Text += "\n" + reader.ReadLine() + "\r\n";
}
}
reader.Close();
}
}