Harness proD API Help
EPLAN.Harness.API Namespace / HpdApi Class / RestoreProject Method
Name of the project backup.
Name of the restored project.
Do you want to overwrite old project with the same name?
Do you want to clean project directory first?
Do you want to preserve backup files during cleaning project directory?
Working folder where the project will be restored. (Default value is Project folder of current version of Harness proD.)
Example
In This Topic
    RestoreProject Method
    In This Topic
    Restore a HpD project.
    Syntax

    Parameters

    backupFilePath
    Name of the project backup.
    projectName
    Name of the restored project.
    overwriteProject
    Do you want to overwrite old project with the same name?
    cleanProjectDir
    Do you want to clean project directory first?
    preserveBackup
    Do you want to preserve backup files during cleaning project directory?
    workingFolder
    Working folder where the project will be restored. (Default value is Project folder of current version of Harness proD.)

    Return Value

    Restored project.
    Exceptions
    ExceptionDescription
    Api is not in an initialized state. You can get current state from Status property. If API is uninitialized, you can initialize it by calling Init(String,String[]) method. If API is in failed state, you can not resurrect it.
    Argument is null.
    Argument is invalid. The exception is thrown when a wrong argument is passed to the method or the setter of property.
    This directory was not found.
    The exception that is thrown when the file has the wrong extension.
    This file was not found.
    Project was not created.
    Document was saved with an unsupported version of HpD.
    Remarks

    Project is opened after this operation.

    If any problem occurs when connecting to the project's active library (for example: wrong version of library) the library will be disconnected. Check project's property EPLAN.Harness.API.Projects.Documents.Project.ActiveConnection if isn't a null reference (Nothing in Visual Basic). For detailed information about what was wrong, see the LOG file or try reconnecting the library using EPLAN.Harness.API.Projects.Documents.Project.ConnectToLibrary. You'll then get the relevant exception.

    Example
    This example shows how to restore a project.
    // API is already initialized.
    HpdApi api = HpdApi.GetInstance();
    
    Project project = api.RestoreProject(@"Path to the backup file (*.hxzproj)", "NewProjectName");
    This example shows how to restore project with overwrite old project with the same name.
    // API is already initialized.
    HpdApi api = HpdApi.GetInstance();
    
    bool overwriteProject = true;
    bool cleanProjectDir = true;
    bool preserveBackup = true;
    
    Project project = api.RestoreProject(@"Path to the backup file (*.hxzproj)", "NewProjectName", overwriteProject, cleanProjectDir, preserveBackup);
    This example shows how to restore project to specific directory.
    // API is already initialized.
    HpdApi api = HpdApi.GetInstance();
    
    string projectLocation = @"Path to a directory";
    
    Project project = api.RestoreProject(@"Path to the backup file (*.hxzproj)", "NewProjectName", workingFolder: projectLocation);
    See Also