Create a Windows forms application. Rename Form1 as MainForm. Drop three text boxes and three combo boxes named txtSiteUrl, txtBaseFileName, txtFileLocation, cboExportMethodType, cboIncludeVersions, and cboDeployObjType, respectively, on the form (along with some labels for them). Drop a button named btnExport on the form. Double-click the button to create a stub for the click event procedure. Add the following code to the constructor and button click event procedures:
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
this.cboExportMethodType.DataSource = Enum.GetValues(typeof(SPExportMethodType));
this.cboIncludeVersions.DataSource = Enum.GetValues(typeof(SPIncludeVersions));
this.cboDeployObjType.DataSource = Enum.GetValues(typeof(SPDeploymentObjectType));
}
private void btnExport_Click(object sender, EventArgs e)
{
SPExportSettings xs = new SPExportSettings();
xs.SiteUrl = this.txtSiteUrl.Text; // @"http://SomeServer:SomePort/";
xs.FileCompression = true;
xs.BaseFileName = this.txtBaseFileName.Text; // "MyExportFileName";
xs.FileLocation = @"c:\temp";
xs.OverwriteExistingDataFile = true;
xs.ExportMethod = (SPExportMethodType)(Enum.Parse(typeof(SPExportMethodType), this.cboExportMethodType.SelectedValue.ToString()));
xs.IncludeVersions = (SPIncludeVersions)(Enum.Parse(typeof(SPIncludeVersions), this.cboIncludeVersions.SelectedValue.ToString()));
SPExportObject xo = new SPExportObject();
if (this.txtSiteUrl.Text.Substring(this.txtSiteUrl.Text.Length - 1, 1) != "/")
this.txtSiteUrl.Text += "/";
xo.Url = this.txtSiteUrl.Text + "SiteCollectionDocuments";
xo.Type = (SPDeploymentObjectType)(Enum.Parse(typeof(SPDeploymentObjectType), this.cboDeployObjType.SelectedValue.ToString()));
xo.ExcludeChildren = false;
xo.IncludeDescendants = SPIncludeDescendants.All;
xs.ExportObjects.Add(xo);
SPExport xe = new SPExport(xs);
xe.Run();
}
}
Run the application. (The combo boxes are bound to the enums, so you do not have to do anything to see your choices.) Choose ExportAll from the export method type combo, All from the include versions combo, and Folder or List from the deployment object type combo. An output file will be created (.cmp file). I noticed that in order to import the data on the other end, it is necessary to specify the .cmp file extension. For example:
SPImportSettings mx = new SPImportSettings();
mx.SiteUrl = @"http://OtherServer:SomePort/";
mx.BaseFileName = "MyExportFileName.cmp";
mx.FileLocation = @"c:\temp";
mx.FileCompression = true;
SPImport me = new SPImport(mx);
me.Run();