Dear all,
I got a problem, that I can read only one record. The other record doesn't show.
The data in file is
001
Phanny
F
Toul Kork
077 95 39 95
123abc
Monday, January 09, 2012
Tuesday, January 31, 2012
good
002
Thary
M
PP
012345678
asf
Tuesday, January 10, 2012
Tuesday, January 10, 2012
good
And the reasult is
001 Phanny F Toul Kork 077 95 39 95 123abc Monday, January 09, 2012 Tuesday,January 31, 2012 good.
This result shows in ListView as below
ID Name Gender Address Phone Passport SartDate EndDate Decriptiom
001 Phanny F PP 077953995 123abc Mon... Tue... good
Here is my code
writing to a file
string tLine = "";
StreamWriter objWriter = new StreamWriter("text.txt",true);
string[] arrTest = new string[9];
arrTest[0] = txtID.Text;
arrTest[1] = txtName.Text;
arrTest[2] = cmbGender.Text;
arrTest[3] = txtAddress.Text;
arrTest[4] = txtPhone.Text;
arrTest[5] = txtPassport.Text;
arrTest[6] = dateTPStartdate.Text;
arrTest[7] = dateTPEndDate.Text;
arrTest[8] = txtDescription.Text;
for (j = 0; j < 9; j++)
{
objWriter.WriteLine(arrTest[j]+" ");
}
objWriter.WriteLine();
objWriter.Close();
Reading from a file
ListViewItem lis = new ListViewItem();
FileInfo afile = new FileInfo("text.txt");
if (afile.Exists)
{
StreamReader objReader = new StreamReader("text.txt", true);
string textLine = "";
do
{
textLine = objReader.ReadLine();
lis.SubItems.Add(textLine);
} while (objReader.Peek() != -1);
listView1.Items.Add(lis);
objReader.Close();
}
else {
MessageBox.Show("There is no file");
}
Please help me.
Thanks