C#粘贴复制数据库中的内容

// Create new 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 sourceDatasetName = (IDatasetName)featureClassName;
sourceDatasetName.WorkspaceName = sourceWorkspaceName;
sourceDatasetName.Name = "Blocks";
IName sourceName = (IName)sourceDatasetName;

// 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 = null;

// 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)
        {
            childEnumNameMapping.Reset();

            // Iterate through each child mapping.
            INameMapping childNameMapping = null;
            while ((childNameMapping = childEnumNameMapping.Next()) != null)
            {
                if (childNameMapping.NameConflicts)
                {
                    childNameMapping.TargetName = childNameMapping.GetSuggestedName
                        (targetName);
                }
            }
        }
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值