How to open a large text file in C#
Posted
by desmati
on Stack Overflow
See other posts from Stack Overflow
or by desmati
Published on 2010-04-25T19:28:46Z
Indexed on
2010/04/25
19:33 UTC
Read the original article
Hit count: 301
I have a text file that contains about 100000 articles. The structure of file is: BEGIN OF FILE .Document ID 42944-YEAR:5 .Date 03\08\11 .Cat political Article Content 1
.Document ID 42945-YEAR:5 .Date 03\08\11 .Cat political Article Content 2 END OF FILE
I want to open this file in c# for processing it line by line. I tried this code:
String[] FileLines = File.ReadAllText(TB_SourceFile.Text).Split(Environment.NewLine.ToCharArray());
But it says: Exception of type 'System.OutOfMemoryException' was thrown.
The question is How can I open this file and read it line by line.
File Size: 564 MB (591,886,626 bytes) File Encoding: UTF-8 File contains Unicode characters.
© Stack Overflow or respective owner