在ARCENGINE下40万条数据的快速读取
仿造ARCMAP下的属性表打开,读取某层40万条数据,要么内存耗尽,要么读取很慢。但在AECMAP下试了一下,速度不慢,不知为何??主要代码:
//要素个数
int k = pFeatureLayer.FeatureClass.FeatureCount(null);
IFeatureCursor pFeatureCursor;
pFeatureCursor = pFeatureLayer.FeatureClass.Search(null, false);
long lTotalRecords = 0;
IFeature pFeature;
pFeature = pFeatureCursor.NextFeature();
string fldValue;
//while (pFeature != null)
for (int j = 0; j < k; j++)
{
if (pFeature !=null)
{
fldValue = new string[pFields.FieldCount];
for (int i = 0; i < pFields.FieldCount; i++)
{
string fldName;
fldName = pFields.get_Field(i).Name;
if (fldName == pFeatureLayer.FeatureClass.ShapeFieldName)
{
fldValue= Convert.ToString(pFeature.Shape.GeometryType);
}
else
{
fldValue[i] = Convert.ToString(pFeature.get_Value(i));
if (fldValue[i].Contains("0:00:00"))
{
string a = fldValue[i].Replace(" 0:00:00", "");
fldValue[i] = a;
}
}
}
dtGridView.Rows.Add(fldValue);
fldValue = null;
System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeature);
pFeature = pFeatureCursor.NextFeature();
lTotalRecords++;
if (lTotalRecords % 100 == 0)
{
GC.Collect();
}
}
}
System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor);
tbarTotalRecords.Text = "共有" + Convert.ToString(lTotalRecords) + "条记录";[/i][/i][/i][/i]
2017-07-12
添加评论
没有找到相关结果
已邀请:
与内容相关的链接