You cannot try:
1) Use System.Numerics.BigInteger to keep the actual line number. - Check after each operation that the line number is not less than it was before, storing the actual line number in BigInteger. Well, in a very huge file, it can actually overflow and become larger than before (after reading, for example, 5 billion line elements in a few internal increments):
var actualLine = new System.Numerics.BigInteger(0); Int32 lastInt32Line = lineInfo.LineNumber; // Some Xml reading Int32 diff = lineInfo.LineNumber - lastLine; // If an overflow has happened - add overflow if (diff >= 0) actualLine += (new BigInteger(Int32.MaxValue)) * 2 - diff; else // Everything is normal - add the diff actualLine += diff;
The real possible problem is that even though you store the line number correctly, the internal elements of the XmlReader may start to crash. In my opinion, the integer arithmetic code checked should be by default, and not uncontrollable, as it is now - when an overflow occurs, the class is damaged, unless it is explicitly specified otherwise.
2) Reorganize the data warehouse to process data more fragmented.
3) Write your own XmlReader that uses BigInteger.
source share