Share via


Web サイトを別の場所に移行する

最終更新日: 2010年1月18日

適用対象: SharePoint Foundation 2010

以下の手順では、コンテンツ移行オブジェクト モデルを使用して SharePoint Foundation Web サイトを別の場所に移行する方法の例を説明します。

Web サイトをエクスポートするには

  1. プロジェクトに以下の using ディレクティブを追加します。

    using System;
    using System.Collections.Generic;
    using System.Windows.Forms;
    using Microsoft.SharePoint;
    using Microsoft.SharePoint.Administration;
    using Microsoft.SharePoint.Deployment;
    
    Imports System
    Imports System.Collections.Generic
    Imports System.Windows.Forms
    Imports Microsoft.SharePoint
    Imports Microsoft.SharePoint.Administration
    Imports Microsoft.SharePoint.Deployment
    
  2. SPExportSettings オブジェクトを作成して、エクスポート操作の設定を指定します。

    SPExportSettings exportSettings = new SPExportSettings();
    
    Dim exportSettings As New SPExportSettings()
    
  3. ソース URL を指定します。

    exportSettings.SiteUrl = "http://webname";
    
    exportSettings.SiteUrl = "http:// webname"
    
  4. 実行するエクスポートの種類を指定します。たとえば、Web サイトのコンテンツをすべてエクスポートしたり、変更の増分のみをエクスポートしたりできます。この例では、すべてのデータをエクスポートします。

    exportSettings.ExportMethod = SPExportMethodType.ExportAll;
    
    exportSettings.ExportMethod = SPExportMethodType.ExportAll
    
  5. 出力ファイル (*.cmp ファイル、Content Migration package とも呼ばれる) の場所を指定します。以下のステートメントでは、c:\exportfile.cmp. にファイルが作成されます。

    exportSettings.BaseFileName = "exportfile";
    exportSettings.FileLocation = @"c:\";
    
    exportSettings.BaseFileName = "exportfile"
    exportSettings.FileLocation = "c:\"
    
  6. データをエクスポートするときに含めるメタデータを決定します。たとえば、バージョン情報を含める必要がありますか ? セキュリティ情報はどうでしょうか ?

    この例では、すべて既定値を使用しています。各アイテムの最新のメジャー バージョンのみが移行されます。ユーザーまたはグループ情報は移行されません。

  7. SPExport クラスの新しいインスタンスを作成し、そのインスタンスを SPExportSettings オブジェクトに渡して、実行します。

    SPExport export = new SPExport(exportSettings);
    Export.Run();
    
    Dim export As New SPExport(exportSettings)
    Export.Run()
    

Web サイトをインポートするには

  1. SPImportSettings クラスのインスタンスを作成して、インポート操作の設定を指定します。

    SPImportSettings importSettings = new SPImportSettings;
    
    Dim importSettings As SPImportSettings = New SPImportSettings
    
  2. エクスポートの手順 3. で作成したコンテンツ移行パッケージの場所を指定します。

    importSettings.BaseFileName = "exportfile";
    importSettings.FileLocation = @"c:\";
    
    importSettings.BaseFileName = "exportfile"
    importSettings.FileLocation = "c:\"
    
  3. Web サイトを作成する場所を指定します。

    importSettings.SiteUrl = "http://newweb";
    
    importSettings.SiteUrl = "http:// newweb"
    
  4. データをインポートするときに含めるメタデータを指定します。たとえば、バージョンの処理方法、ファイルの作成者や編集者の情報、および GUID を保持するかどうかを指定します。

    ここでも既定値を使用します。新しいバージョンは追加され、作成者や編集者の情報や GUID はインポートされません。

  5. SPImport クラスの新しいインスタンスを作成し、そのインスタンスを SPImportSettings オブジェクトに渡して、実行します。

    SPImport import = new SPImport(importSettings);
    Import.Run();
    
    Dim import As New SPImport(importSettings)
    Import.Run()
    

関連項目

概念

コンテンツ移行オブジェクト モデルを使用する