954,529 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Streamreader stops reading

So I am trying to create a console app to parse text files. I am using a streamreader to read the text in until I reach end of file. The text file I am reading as 22945 lines. Right now I am just trying to read the entire file and write it to another file. The new file ends at line 22926. Does any body have any idea why? Is there a limit to how much data I can read through a streamreader? The code I am using is this:

while(!fs.EndOfStream)
{
     line = fs.ReadLine();
     fw.WriteLine(line);
}
jt_murphree
Light Poster
40 posts since Dec 2008
Reputation Points: 34
Solved Threads: 2
 

If it's just text, it should not be a problem.
Are you running into any binary characters?

Would something like this also fail?:

File.WriteAllLines(@"c:\science\out.txt", File.ReadAllLines(@"c:\science\data.txt"));
thines01
Postaholic
Team Colleague
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402
 

Actually I just discovered that it was not an issue with the stream that was reading but the one that was writeing. I was not flushing it. Now I have that issue solved. Still have a couple of others but I am not at the point of having to ask for help yet. I may be there soon tough!!!!!!

jt_murphree
Light Poster
40 posts since Dec 2008
Reputation Points: 34
Solved Threads: 2
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You