I need to read a 950mb txt file in a console app without getting a System.OutOfMemoryException, with the following structure:
"6152902100000017";20110701;20110701;53;"D";30359130;"NOTA DE DEBITO";"DEB.COMPRA BCO";0;;0;"6152902100000017";0;0;0;0;0;"902"
I can read smaller files but the exception is thrown on bigger files.
Any suggestions?
The following will almost always fail, 950MB at 2 Bytes/char is too close to the 2GB limit :
Reading it as an array of string will probably work (esp on a 64 bit system) if you have 4+ GB:
But your best bet is to process it 1 line at a time: