I happened to work on files. My condition to read the file line by line.
Here is a small piece of code to read the file line by line.... I got the snippet from Microsoft BOL.
Happy Coding
Cheers,
Venkatesan Prabu .J
Head, KaaShiv InfoTech.
Chennai
www.kaashivinfotech.com
Here is a small piece of code to read the file line by line.... I got the snippet from Microsoft BOL.
private void btnBrowse_Click(object sender, EventArgs e)
{
int counter = 0;
string line;
rtb_filecontent.Text = "";
// Read the file and display it line by line.
System.IO.StreamReader file =
new System.IO.StreamReader("D:\\1.txt");
this.listBox1.TopIndex = 0;
while ((line = file.ReadLine()) != null)
{
// rtb_filecontent.Text = rtb_filecontent.Text + "\n" + line;
listBox1.Items.Add(line);
//rtb_filecontent.AutoScrollOffset = new Point(rtb_filecontent.AutoScrollOffset.Y, 10);
Thread.Sleep(200);
counter++;
}
file.Close();
}
{
int counter = 0;
string line;
rtb_filecontent.Text = "";
// Read the file and display it line by line.
System.IO.StreamReader file =
new System.IO.StreamReader("D:\\1.txt");
this.listBox1.TopIndex = 0;
while ((line = file.ReadLine()) != null)
{
// rtb_filecontent.Text = rtb_filecontent.Text + "\n" + line;
listBox1.Items.Add(line);
//rtb_filecontent.AutoScrollOffset = new Point(rtb_filecontent.AutoScrollOffset.Y, 10);
Thread.Sleep(200);
counter++;
}
file.Close();
}
Happy Coding
Cheers,
Venkatesan Prabu .J
Head, KaaShiv InfoTech.
Chennai
www.kaashivinfotech.com
No comments:
Post a Comment