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
Arunkumar EmmPosted Jun 1, 2010, 3:04 AM
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.
mubashir hafeezPosted May 31, 2010, 2:25 PM
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];
}
}
}
Lalit MPosted May 31, 2010, 6:13 AM
You will get help from this link