public staticvoidGdbTransfer(IWorkspaceName sourceWorkspaceName, IWorkspaceName targetWorkspaceName, string sourceDatasetName)
{
//// Create workspace name objects.//IWorkspaceName sourceWorkspaceName = new WorkspaceNameClass();//IWorkspaceName targetWorkspaceName = new WorkspaceNameClass();
IName targetName = (IName) targetWorkspaceName;
//// Set the workspace name properties.//sourceWorkspaceName.PathName = @"C:\arcgis\ArcTutor\BuildingaGeodatabase\Montgomery.gdb";//sourceWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesGDB.FileGDBWorkspaceFactory";//targetWorkspaceName.PathName = @"PartialMontgomery.gdb";//targetWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesGDB.FileGDBWorkspaceFactory";// Create a name object for the source feature class.
IFeatureClassName featureClassName = new FeatureClassNameClass();
// Set the featureClassName properties.
IDatasetName pSourceDatasetName = (IDatasetName) featureClassName;
pSourceDatasetName.WorkspaceName = sourceWorkspaceName;
pSourceDatasetName.Name = sourceDatasetName;
IName sourceName = (IName)pSourceDatasetName;
// Create an enumerator for source datasets.
IEnumName sourceEnumName = new NamesEnumeratorClass();
IEnumNameEdit sourceEnumNameEdit = (IEnumNameEdit) sourceEnumName;
// Add the name object for the source class to the enumerator.
sourceEnumNameEdit.Add(sourceName);
// Create a GeoDBDataTransfer object and a null name mapping enumerator.
IGeoDBDataTransfer geoDBDataTransfer = new GeoDBDataTransferClass();
IEnumNameMapping enumNameMapping;
// Use the data transfer object to create a name mapping enumerator.
Boolean conflictsFound = geoDBDataTransfer.GenerateNameMapping(sourceEnumName, targetName, out enumNameMapping);
enumNameMapping.Reset();
// Check for conflicts.if (conflictsFound)
{
// Iterate through each name mapping.
INameMapping nameMapping = null;
while ((nameMapping = enumNameMapping.Next()) != null)
{
// Resolve the mapping's conflict (if there is one).if (nameMapping.NameConflicts)
nameMapping.TargetName = nameMapping.GetSuggestedName(targetName);
// See if the mapping's children have conflicts.
IEnumNameMapping childEnumNameMapping = nameMapping.Children;
if (childEnumNameMapping == null) continue;
childEnumNameMapping.Reset();
// Iterate through each child mapping.
INameMapping childNameMapping = null;
while ((childNameMapping = childEnumNameMapping.Next()) != null)
{
if (childNameMapping.NameConflicts)
childNameMapping.TargetName = childNameMapping.GetSuggestedName(targetName);
}
}
}
// Start the transfer.
geoDBDataTransfer.Transfer(enumNameMapping, targetName);
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?