chennaiprogrammer
Programmer
- Jul 31, 1999
- 54
private System.IO.StreamWriter sw;
private System.IO.StreamReader sr;
string path=@"E:\projects\file1.txt";
void MainFormLoad(object sender, System.EventArgs e)
{
sr=File.OpenText (path);
listBox1.Items.Clear ();
while((sr.Read ())!=-1)
{
listBox1.Items.Add (sr.ReadLine ());
}
sr.Close ();
}
}
}
Now if file1.txt contains
the data
firstline
secondline
thirdline
fourthline
The output comes as
irstline
econdline
hirdline
ourthline
The first character of each line gets truncated
Please advise how to overcome this problem ?
chris
private System.IO.StreamReader sr;
string path=@"E:\projects\file1.txt";
void MainFormLoad(object sender, System.EventArgs e)
{
sr=File.OpenText (path);
listBox1.Items.Clear ();
while((sr.Read ())!=-1)
{
listBox1.Items.Add (sr.ReadLine ());
}
sr.Close ();
}
}
}
Now if file1.txt contains
the data
firstline
secondline
thirdline
fourthline
The output comes as
irstline
econdline
hirdline
ourthline
The first character of each line gets truncated
Please advise how to overcome this problem ?
chris