读取的文件比较大,有49M,对这同一个文件进行读取的时候,就会报错,报错区代码如下,第一次读49M文件时没问题,但是第二次读时在下面代码里面第三行代码处就会报OutOfMemoryException的问题,这个怎么解决?谢谢private string GetEDFInfo(string line,System.Windows.Forms.Label tb)
{
string docName = string.Empty;
string[] docs = line.Split(new string[]{"rename DOC \"Doc\""},StringSplitOptions.RemoveEmptyEntries);
for(int i = 0;i<docs.Length;i++)
{
string[] docNames = docs[i].Split(new string[] {"\r\n"},StringSplitOptions.RemoveEmptyEntries);
if(docNames[2].Contains("stringDisplay"))
{
docName = docNames[2].Trim();
int firstDoc = docName.Index("\"");
int lastDoc = docName.LastIndexOf("\"");
if(firstDoc + 1 != lastDoc)
{
docName = docName.Substring(firstDoc+1,lastDoc - firstDoc-1);
tb.Text = "Doc:"+docName;
break;
}
}
if(docName == "")
{
return "aaaaaaa";
}
else
{
docName ="";
line = null;
docName = null;
docs = null;
GC.Collect();
}
}
return tb.Text;
}
{
string docName = string.Empty;
string[] docs = line.Split(new string[]{"rename DOC \"Doc\""},StringSplitOptions.RemoveEmptyEntries);
for(int i = 0;i<docs.Length;i++)
{
string[] docNames = docs[i].Split(new string[] {"\r\n"},StringSplitOptions.RemoveEmptyEntries);
if(docNames[2].Contains("stringDisplay"))
{
docName = docNames[2].Trim();
int firstDoc = docName.Index("\"");
int lastDoc = docName.LastIndexOf("\"");
if(firstDoc + 1 != lastDoc)
{
docName = docName.Substring(firstDoc+1,lastDoc - firstDoc-1);
tb.Text = "Doc:"+docName;
break;
}
}
if(docName == "")
{
return "aaaaaaa";
}
else
{
docName ="";
line = null;
docName = null;
docs = null;
GC.Collect();
}
}
return tb.Text;
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货