C#粘貼複製資料庫中的內容

來源:互聯網
上載者:User

// 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);
                }
            }
        }
    }
}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.