मैं टैब अलग फ़ाइल पढ़ने के लिए अपने सी # कोड में string.split() का उपयोग कर रहा हूं। मुझे कोड आउटपुट में नीचे उल्लिखित "आउटऑफमेमरी अपवाद" का सामना करना पड़ रहा है।string.split() "अलग अपवाद से बाहर" टैब अलग फ़ाइल पढ़ने पर
यहां मैं जानना चाहूंगा कि फाइल 16 एमबी आकार के लिए समस्या क्यों आ रही है?
यह सही दृष्टिकोण है या नहीं?
using (StreamReader reader = new StreamReader(_path))
{
//...........Load the first line of the file................
string headerLine = reader.ReadLine();
MeterDataIPValueList objMeterDataList = new MeterDataIPValueList();
string[] seperator = new string[1]; //used to sepreate lines of file
seperator[0] = "\r\n";
//.............Load Records of file into string array and remove all empty lines of file.................
string[] line = reader.ReadToEnd().Split(seperator, StringSplitOptions.RemoveEmptyEntries);
int noOfLines = line.Count();
if (noOfLines == 0)
{
mFileValidationErrors.Append(ConstMsgStrings.headerOnly + Environment.NewLine);
}
//...............If file contains records also with header line..............
else
{
string[] headers = headerLine.Split('\t');
int noOfColumns = headers.Count();
//.........Create table structure.............
objValidateRecordsTable.Columns.Add("SerialNo");
objValidateRecordsTable.Columns.Add("SurveyDate");
objValidateRecordsTable.Columns.Add("Interval");
objValidateRecordsTable.Columns.Add("Status");
objValidateRecordsTable.Columns.Add("Consumption");
//........Fill objValidateRecordsTable table by string array contents ............
int recordNumber; // used for log
#region ..............Fill objValidateRecordsTable.....................
seperator[0] = "\t";
for (int lineNo = 0; lineNo < noOfLines; lineNo++)
{
recordNumber = lineNo + 1;
**string[] recordFields = line[lineNo].Split(seperator, StringSplitOptions.RemoveEmptyEntries);** // Showing me error when we split columns
if (recordFields.Count() == noOfColumns)
{
//Do processing
}
एक तरफ, एरिक लिपर्ट के पास आउटऑफमेमरी अपवादों पर एक महान ब्लॉग है। http://blogs.msdn.com/ericlippert/archive/2009/06/08/out-of-memory-does-not-refer-to-physical-memory.aspx –
क्या यह कॉम्पैक्ट फ्रेमवर्क पर है (यानी विंडोज मोबाइल)? – MusiGenesis