/// <summary>
/// 得到所有的圖層
/// </summary>
/// <returns></returns>
public static List<string> GetLayerNameList()
{
List<string> layerNameList = new List<string>();
IWorkspace workSpace = CommonUtils.GetSdeIWorkSpace();
IEnumDatasetName enumDatasetName;
IDatasetName datasetName;
//擷取圖層名
enumDatasetName = workSpace.get_DatasetNames(esriDatasetType.esriDTFeatureClass);
datasetName = enumDatasetName.Next();
while (datasetName != null)
{
layerNameList.Add(datasetName.Name);
datasetName = enumDatasetName.Next();
}
CommonUtils.RelComObject(enumDatasetName);
CommonUtils.RelComObject(workSpace);
return layerNameList;
}
/// <summary>
/// 得到對應層字段
/// </summary>
/// <param name="layerName">層名</param>
/// <returns></returns>
public static List<string> GetFieldNameList(string layerName)
{
IFeatureClass featureClass = (CommonUtils.GetSdeIWorkSpace() as IFeatureWorkspace).OpenFeatureClass(layerName);
IFields pFields = featureClass.Fields; //擷取圖層的字段
List<string> fieldNameList = new List<string>();
for (int i = 0; i < pFields.FieldCount; i++)
{
fieldNameList.Add(pFields.get_Field(i).Name);
}
return fieldNameList;
}