Hi ,
i have to develop a C# application which reads the text from a .txt
file, and i have to write the contents of the file to textboxes.
the format of the .txt file is something like this,
1. arun 23 nano xyz 9898989
2. emm 24 soft abc 9988989
i have to develop a application which has some 5 textboxes and each has the value of different columns from the text file. Hope u understood what i am trying to tell. Pls help me on this.
Thanks in advance.
Regards
Emm.
Loading

Lalit MRank #1,186 · 1.5K reputationPosted May 31, 2010, 2:13 AM EDT
You will get help from this link
mubashir hafeez5 reputationPosted May 31, 2010, 10:25 AM EDT
Create txt file in your c:\test.txt
arun 23 nano xyz 9898989
emm 24 soft abc 9988989
Don't forget to add the following
using System.IO;
private void button1_Click(object sender, EventArgs e)
{
using (StreamReader sr = File.OpenText(@"c:\test.txt"))
{
string input = null;
while ((input = sr.ReadLine()) != null)
{
string [] arrlist = input.Split(' ');
textBox1.Text = arrlist[0];
textBox2.Text = arrlist[1];
textBox3.Text = arrlist[2];
textBox4.Text = arrlist[3];
textBox5.Text = arrlist[4];
}
}
}
Arunkumar Emm59 reputationPosted May 31, 2010, 11:04 PM EDT
string [] arrlist = input.Split(' '),System.StringSplitOptions.RemoveEmptyEntries;
to remove the empty spaces between columns in the .txt file. thank you so much for ur help. now i need to write these textbox values to an excel sheet. how do i do that?..
Regards
Emm.