FRAMES | NO FRAMES
RenameProject Method

Renames an existing project.

Availability: Business Analyst Server.

void RenameProject ( 
    string  WorkspaceName, 
    string  ProjectName, 
    string  NewProjectName 
);

Parameter Description
WorkspaceName Workspace name. Type String.
ProjectName Project name. Type String.
NewProjectName New project name. Type String.

Remarks

If the source project is absent or the target project already exists, this method throws an exception. The method also throws an exception in attempt to rename a project to itself.

Examples

The example below renames a project in the Default Workspace of the Business Analyst Server Repository. In order to demonstrate this method, a new project is created and then renamed.

C#
// Instantiate the BAServerHelper class to access analysis methods
BAServerHelper baServerHelper = new BAServerHelper();
 
string workspace = "Default Workspace";
string sourceProject = "project_RenameProject";
string targetProject = "project_RenamedProject";
 
// Create the source project
// Before creating this project we try to remove it just in case.
try { baServerHelper.DeleteProject(workspace, sourceProject); }
catch { }
baServerHelper.CreateProject(workspace, sourceProject);
 
// Rename the source project to the target one
// Before renaming this project we try to remove the target project just in case.
try { baServerHelper.DeleteProject(workspace, targetProject); }
catch { }
baServerHelper.RenameProject(workspace, sourceProject, targetProject);
 
// Get the list of all projects and ensure that the source project is absent
// and the target project exists
string[] projects = baServerHelper.GetProjects(workspace);
bool sourceMissing = Array.IndexOf(projects, sourceProject) < 0;
bool targetFound = Array.IndexOf(projects, targetProject) >= 0;
 
// Remove the target project
baServerHelper.DeleteProject(workspace, targetProject);

See Also