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
matthew king
NA
52
0
Streamreader, .txt file
Mar 26 2010 9:45 PM
Sir/Ma'am
I have a .txt file int the following format:
[test1]
blue
red
green
[test2]
one
two
three
[test3]
white
black
grey
I'm trying to read the everything below [test2] and above [test3] into a combobox. So, I'm trying to populate comboBox1 with one, two, and three. I thought this might work, but I was wrong:
{
comboBox1.Items.Clear();
using
(
StreamReader
sr =
new
StreamReader
(
@"c:\test.cfg"
))
{
String
line1;
do
{
line1 = sr.ReadLine();
if
(line1.StartsWith(
"[test2"
))
{
line1 = line1.Split(
']'
)[1].Trim();
String
[] strgArray;
strgArray = line1.Split(
'\n'
);
foreach
(
String
strg
in
strgArray)
{
comboBox1.Items.Add(strg.Trim());
}
break
;
}
}
while
((line1 !=
null
));
Console
.Read();
}
}
}
THANK YOU!!!
Reply
Answers (
4
)
how to create crystal reports in c# windows application
convert .apllication to exe