Folder::Subfolders

Description

Access subfolders as a collection.


Get a subfolder by index.


Get a subfolder by name

Syntax

Collection<Folder> Subfolders

Folder Subfolders(int nIndex)

Folder Subfolders(LPCSTR lpcszName)

Parameters

index
[input] The index (from zero) of subfolders

lpcszName
[input] The name of the folder

Return

Returns a folder object.


Returns a folder object.

Examples

EX1

// List the folders and pages within the active folder
void    Folder_Subfolders_Ex1()
{
    string strName;
    Folder fld = Project.ActiveFolder();
    foreach(Folder sub in fld.Subfolders) // Subfolders is a collection
    {
        strName = sub.GetName();
        printf("<Folder> %s\n", strName );
    } 
    foreach(PageBase page in fld.Pages) // Pages is another collection
    {
        strName = page.GetName();
        printf("%s\n", strName );
    }
}

EX2

// Get the name of the first subfolder of root by index
void       Folder_Subfolders_Ex2()
{
        Folder fld = Project.RootFolder;
        Folder subfld = fld.Subfolders(0); // The Subfolders collection is indexed from 0
        if(subfld.IsValid())
                out_str("The first subfolder is : " + subfld.GetName());
        else
                out_str("There are no subfolders");
}

EX3

// Get a subfolder by name
void       Folder_Subfolders_Ex3()
{
        Folder fld = Project.RootFolder;
        Folder fldsub = fld.Subfolders("MyFolder");
        if( fldsub.IsValid() )
                printf("Found the subfolder of root named 'MyFolder'\n");
        else
                printf("No subfolder of root named 'MyFolder'\n");
}

Remark

header to Include

origin.h

See Also

Folder::Pages

Reference