/// <summary> /// 重命名 /// </summary> /// <param name="newName"></param> public void ReName(string newName) { IDataset ds = featureClass as IDataset; if (ds.CanRename()) { ds.Rename(newName); } }
/// <summary> /// 重命名 /// </summary> /// <param name="newName"></param> public static void ReName(this IFeatureClass featureClass, string newName) { IDataset ds = featureClass as IDataset; if (ds.CanRename()) { ds.Rename(newName); } }
public static void Import2(string savemdbFile, string sourcemdbFile, List <StockTable> tables, string XZSDM, string XZSMC) { IWorkspace workspaceA = savemdbFile.OpenAccessFileWorkSpace(); IFeatureWorkspace featureWorkspace = workspaceA as IFeatureWorkspace; IFeatureWorkspaceManage featureWorkspaceManagerA = featureWorkspace as IFeatureWorkspaceManage; IWorkspace workspaceB = sourcemdbFile.OpenAccessFileWorkSpace(); foreach (var table in tables) { if (table.IsSpace == false) { continue; } var outfeatureClassName = table.Name + "_Merge"; if (!MergeFeatureClass(string.Format("{0}\\{1};{2}\\{1}", savemdbFile, table.Name, sourcemdbFile), null, string.Format("{0}\\{1}", savemdbFile, outfeatureClassName))) { Console.WriteLine("Merge失败"); continue; } IFeatureClass featureClassA = workspaceA.GetFeatureClass(table.Name); IDataset datasetA = featureClassA as IDataset; datasetA.Delete(); IFeatureClass featureClassAC = workspaceA.GetFeatureClass(outfeatureClassName); if (featureClassAC != null) { IDataset datasetAc = featureClassAC as IDataset; try { if (datasetAc.CanRename()) { datasetAc.Rename(table.Name); } } catch { Console.WriteLine("重命名失败"); } } Marshal.ReleaseComObject(featureClassA); } Marshal.ReleaseComObject(workspaceA); Marshal.ReleaseComObject(workspaceB); }
public bool CanRename() { try { IDataset dataset = this.Dataset; if (dataset != null) { bool flag = false; flag = dataset.CanRename(); dataset = null; return(flag); } } catch { } return(false); }