Sanjay Sharma

Sanjay Sharma

  • 1.2k
  • 409
  • 25.4k

Exception of type 'System.OutOfMemoryException' was thrown.

Aug 22 2019 8:14 AM
Hi,
 
I have two csv files Say 'File1.csv" (# records 3239972) & "File2.csv" (# 8927549).
 
So what I am doing Is I am polulating dataset by reading File Line by Line as. 
 
DataTable dtCsv = new DataTable();
int i = 0;
foreach (var line in File.ReadLines(FilePath))
{
  DataRow dr = dtCsv.NewRow();
//Set dr for columns 
 dtCsv.Rows.Add(dr); //add other rows  
 
return  dtCsv;
 
==================
This works fine for  'File1.csv" (# records 3239972)
but give an error  'System.OutOfMemoryException' after processing Row # 8147077 added to datatable
 
 Please help its nightmare for me and client is sitting on my head :(
 

Answers (5)