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
Vjatseslav Krosin
NA
34
2.1k
Problem with using 2 StreamReaders
Aug 31 2011 11:58 AM
Hi, i have a problem using 2 StreamReaders like this:
private void
Window_Loaded(
object
sender,
RoutedEventArgs
e)
{
FileInfo
file =
new
FileInfo
(
"key.txt"
);
FileInfo
file2 =
new
FileInfo
(
"value.txt"
);
StreamReader
stRead
= file.OpenText();
using
(stRead)
{
while
(!stRead.EndOfStream)
{
string
key = stRead.ReadLine();
listBox1.Items.Add(key);
countItems++;
numberCount.Content = countItems.ToString();
}
}
StreamReader
stRead2 = file2.OpenText();
using
(stRead2)
{
while
(!stRead2.EndOfStream)
{
string
key = stRead.ReadLine();
string
value = stRead2.ReadLine();
if
(value !=
null
)
if
(key !=
null
) list.Add(key, value);
}
}
}
The first one works fine (stRead), but when it gets to second one (stRead2), then it get the while statement !stRead2.EndOfStream == true and it skips the loop for some reason, can anyone help me? And will the list.Add() even work in the list?
Reply
Answers (
2
)
Help me to run oracle package (uniface) from .net ?
Column from Excel Sheet