AI agents: the content index is at /llms.txt. Every page is also available as Markdown — send the request header Accept: text/markdown, or append .md to the page URL.
Xperience Docs

Cookie consent

We use necessary cookies (opens in a new tab) to run our website and improve your experience while browsing. Additional cookies are only used with your consent. You may revoke your consent on the Cookies Policy (opens in a new tab) page or in your browser at any time.

Configure (opens in a new tab)
  • Documentation
    InstallationUsing the Xperience interfaceDeveloping websitesConfiguring XperienceManaging usersSecuring websitesDeploying websitesManaging website contentMultilingual websitesMacro expressionsExternal utilitiesIntegrating 3rd party systemsCustom developmentE-commerce featuresOn-line marketing featuresRelease notes - Xperience 13Xperience terminology glossary
  • Tutorial
    Using the Xperience interfaceDeveloper tutorialBusiness tutorialResource hub for marketers
  • API Examples
    ConfigurationContent managementDevelopmentE-commerceOn-line marketingSocial media
  1. Home
  2. Configuration
  3. Import and export

Import and export


Was this page helpful?

Send us feedback Go back to top
  • Community Questions & Answers (opens in a new tab)
  • Contact support (opens in a new tab)

List of examples:

  • Import
    • Importing an object
    • Importing a site
  • Export
    • Exporting an object (user)
    • Exporting a site
    • Deleting export packages from the file system

Import

Importing an object

C#
// Creates an object containing the import settings
SiteImportSettings settings = new SiteImportSettings(MembershipContext.AuthenticatedUser);

// Initializes the import settings
settings.SourceFilePath = "Packages\\APIExample_User.zip";
settings.ImportType = ImportTypeEnum.AllNonConflicting;
settings.LoadDefaultSelection();

// Imports the package
ImportProvider.ImportObjectsData(settings);

// Deletes temporary data
ImportProvider.DeleteTemporaryFiles(settings, false);
> Back to list of examples

Importing a site

C#
// Prepares the site import parameters
string websitePath = System.Web.HttpContext.Current.Server.MapPath("~/");
string sourceFilePath = "Packages\\APIExample_Site.zip";
string siteDisplayName = "Imported site";
string siteName = "ImportedSite";
string siteDomain = "127.0.0.1";

// Verifies that the system does not already contain a site with the given name
if (SiteInfo.Provider.Get(siteName) == null)
{
    // Imports the site
    ImportProvider.ImportSite(siteName, siteDisplayName, siteDomain, sourceFilePath, websitePath, MembershipContext.AuthenticatedUser);
}
> Back to list of examples

Export

Exporting an object (user)

C#
// Deletes temporary export files
try
{
    ExportProvider.DeleteTemporaryFiles();
}
catch
{
}

// Gets the user
UserInfo exportedUser = UserInfo.Provider.Get("Username");

// Ensures that the user exists
if (exportedUser != null)
{
    // Prepares the export parameters
    string websitePath = System.Web.HttpContext.Current.Server.MapPath("~/");
    string exportFileName = string.Format("APIExample_User_{0:yyyy-MM-dd_hh-mm}.zip", DateTime.Now);
    string exportFilePath = FileHelper.GetFullFilePhysicalPath(ImportExportHelper.GetSiteUtilsFolder(), websitePath) + "Export\\" + exportFileName;

    // Verifies that an export package with the given name doesn't already exist
    if (!File.Exists(exportFilePath))
    {
        // Exports the user object
        ExportProvider.ExportObject(exportedUser, exportFilePath, websitePath, MembershipContext.AuthenticatedUser);
    }
}
> Back to list of examples

Exporting a site

C#
// Deletes temporary export files
try
{
    ExportProvider.DeleteTemporaryFiles();
}
catch
{
}

// Prepares the export parameters
string websitePath = System.Web.HttpContext.Current.Server.MapPath("~/");
string exportFileName = string.Format("APIExample_Site_{0:yyyy-MM-dd_hh-mm}.zip", DateTime.Now);
string exportFilePath = FileHelper.GetFullFolderPhysicalPath(ImportExportHelper.GetSiteUtilsFolder(), websitePath) + "Export\\" + exportFileName;
string siteName = "ImportedSite";

// Verifies that the site exists
if (SiteInfo.Provider.Get(siteName) != null)
{
    // Verifies that an export package with the given name doesn't already exist
    if (!File.Exists(exportFilePath))
    {
        // Exports the site
        ExportProvider.ExportSite(siteName, exportFilePath, websitePath, false, MembershipContext.AuthenticatedUser);
    }
}
> Back to list of examples

Deleting export packages from the file system

C#
// Prepares package parameters
string websitePath = System.Web.HttpContext.Current.Server.MapPath("~/");
string exportPath = FileHelper.GetFullFolderPhysicalPath(ImportExportHelper.GetSiteUtilsFolder(), websitePath) + "Export\\";
string filesToDelete = @"APIExample*.zip";

// Gets a list of export packages
string[] fileList = Directory.GetFiles(exportPath, filesToDelete);

// Deletes the files
foreach (string file in fileList)
{
    try
    {
        File.Delete(file);
    }
    catch
    {
        // Deletion was unsuccessful
    }
}
> Back to list of examples