TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
kristen ko
NA
9
0
Reading text files and creating string for necessary infos.
Apr 12 2010 6:28 AM
Hello,
I am beginner in C# and I need your help.
I can read the file and I can see it in my richtextbox. But I do not want to see all of lines in richtextbox. I want to see lines which are begin with MR, MISS and CHD. I can not do that. Than, I will save them to the my database. My text file is like that:
1 MR HANN CO 03.04.10 10.04.10 7 1XDouble Room Balcony ( All Inclusive 278115
2 CHD. INGA CO 13J.
3 MISS JON, BIRGITTA 03.04.10 10.04.10 7 1XDeluxe Suite, Balcony All Inclusive 278115 GOT FHY836
4 MR JONSSON, PER
5 CHD JONSSON, OSKAR 12J.
6 CHD JONSSON, JAKOB 9J.
7 CHD JONSSON, ISAK 5J.
8 MISS NAIMER, HENNA 03.04.10 10.04.10 7 1XFamily Suite Balcony All Inclusive 411622 HEL XQ 6525
My codes are:
namespace ANALYZE
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog fdlg = new OpenFileDialog();
fdlg.Title = "Open File";
fdlg.InitialDirectory = @"c:\";
fdlg.Filter = "Text files(*.txt)|*.txt";
fdlg.FilterIndex = 2;
fdlg.RestoreDirectory = true;
fdlg.RestoreDirectory = true;
if (fdlg.ShowDialog() == DialogResult.OK)
{
textBox1.Text = fdlg.FileName;
}
}
private void button2_Click(object sender, EventArgs e)
{
if (textBox1.Text == string.Empty)
{
MessageBox.Show("Please browse text file!");
}
FileStream akis;
StreamReader Okuma;
string Yol = textBox1.Text;
akis = new FileStream(Yol, FileMode.Open, FileAccess.Read);
Okuma = new StreamReader(akis);
richTextBox1.Text = Okuma.ReadToEnd(); // I can just do this. but here, I want to see necessary informations.
MessageBox.Show("Operation is completed.");
Attachment:
Connection office.rar
Reply
Answers (
7
)
GDI+ drawing have flicker/ slow down, need solution
Login Problem in C#