1.9.2 Managing Folders


Pages in an Origin project (workbooks, matrixbooks, and graphs) can be organized in a hierarchical folder structure, visible in Origin's Project Explorer. The Origin C Folder class allows you to create, activate, select, and arrange folders.

Create a Folder and Get Its Path

Folder fldRoot, fldSub;
fldRoot = Project.RootFolder;

// Add a sub folder in root folder with name
fldSub = fldRoot.AddSubfolder("MyFolder");
printf("Folder added successfully, path is %s\n", fldSub.GetPath());

Get the Active Folder

Folder fldActive;
fldActive = Project.ActiveFolder();

// Add a sub folder to it
Folder fldSub;
fldSub = fldActive.AddSubfolder("MyFolder");
printf("Folder added successfully, path is %s\n", fldSub.GetPath());

Activate a Folder

// activate root folder
Folder fldRoot = Project.RootFolder;
fldRoot.Activate();

// activate the specified sub folder
Folder fldSub("/MyFolder");
fldSub.Activate();

Get Path for a Specific Page

GraphPage gp("Graph1");
if( gp.IsValid() )
{
	Folder fld = gp.GetFolder();
	out_str(fld.GetPath());
}

Move a Page/Folder to Another Location

Folder::Move is used to move a window (Worksheet, Graph...) or folder to another location. The following example shows how to move a folder.

// Add two sub folders to root folder
Folder subfld1 = Project.RootFolder.AddSubfolder("sub1");
Folder subfld2 = Project.RootFolder.AddSubfolder("sub2");
 
// Move the sub2 folder under the sub1 folder
if( !Project.RootFolder.Move(subfld2.GetName(), "/"+subfld1.GetName()+"/", true) )
    printf("move folder failed!");