using
System;
System.Collections.Generic;
System.Linq;
System.Text;
Microsoft.SharePoint;
Microsoft.SharePoint.Deployment;
namespace
SiteExportImport
{
class
Program
static
void
Main(
string
[] args)
Console.WriteLine(
"Please input the source site URL "
);
//Enter URL of your source site
String sourceSite = Console.ReadLine();
"Please input the destination site URL"
//Enter URL of your destination site
String destinationSite = Console.ReadLine();
"Please input the destination file location"
//Enter the location where you want your exported files to be generated
String fileLocation = Console.ReadLine();
"Please input the Base file name"
//Enter the name of your exported file
String baseFileName = Console.ReadLine();
"Please input the export log file location"
//Enter full path including the name of your export log file
String exportlogLocation = Console.ReadLine();
"Please input the import log file location"
//Enter full path including the name of your import log file
String importlogLocation = Console.ReadLine();
SPImport import =
new
SPImport();
SPExport export =
SPExport();
SPExportSettings exportSettings = export.Settings;
exportSettings.SiteUrl = sourceSite;
exportSettings.CommandLineVerbose =
true
;
exportSettings.ExportMethod = SPExportMethodType.ExportAll;
exportSettings.FileLocation = fileLocation;
exportSettings.BaseFileName = baseFileName;
exportSettings.LogFilePath = exportlogLocation;
exportSettings.OverwriteExistingDataFile =
export.Run();
"Export Completed"
SPImportSettings importSettings = import.Settings;
importSettings.BaseFileName = baseFileName;
importSettings.CommandLineVerbose =
importSettings.FileLocation = fileLocation;
importSettings.LogFilePath = importlogLocation;
importSettings.SiteUrl = destinationSite;
import.Run();
"Import Completed"
Console.ReadLine();
}