FolderInfo.AddSubFolder

AddSubFolder(string, bool)

Adds a subfolder. With createHierarchy, the name can be a path, and the missing folders are created.

public FolderInfo AddSubFolder(string name, bool createHierarchy)
ParameterTypeDescription
nameStringThe name of the subfolder, or a path such as Parent\Child when createHierarchy is true.
createHierarchyBooleantrue to treat name as a path separated by backslashes and create the folders that do not exist yet.

Return Value

The new subfolder.

Exceptions

exceptioncondition
NotImplementedExceptionThe PST is in the ANSI format, which cannot be edited.
ArgumentNullExceptionname is null or empty.
InvalidOperationExceptionThe PST is open for reading only.

Remarks

The new folder gets the container class of this folder, or IPF.Note if this folder has none.

See Also


AddSubFolder(string)

Adds a subfolder with the specified name.

public FolderInfo AddSubFolder(string name)
ParameterTypeDescription
nameStringThe name of the subfolder.

Return Value

The new subfolder.

Exceptions

exceptioncondition
NotImplementedExceptionThe PST is in the ANSI format, which cannot be edited.
ArgumentNullExceptionname is null or empty.
InvalidOperationExceptionThe PST is open for reading only.
InvalidOperationExceptionA subfolder with this name already exists. Names are compared case-insensitively.

Remarks

The new folder gets the container class of this folder, or IPF.Note if this folder has none.

See Also


AddSubFolder(string, string)

Adds a subfolder with the specified name and container class.

public FolderInfo AddSubFolder(string name, string containerClass)
ParameterTypeDescription
nameStringThe name of the subfolder.
containerClassStringThe container class of the new folder, for example IPF.Note for mail or IPF.Appointment for a calendar.

Return Value

The new subfolder.

Exceptions

exceptioncondition
NotImplementedExceptionThe PST is in the ANSI format, which cannot be edited.
ArgumentNullExceptionname is null or empty.
InvalidOperationExceptionThe PST is open for reading only.
InvalidOperationExceptionA subfolder with this name already exists. Names are compared case-insensitively.

See Also


AddSubFolder(string, FolderCreationOptions)

Adds a subfolder with the specified name to the current folder using the provided creation options.

public FolderInfo AddSubFolder(string name, FolderCreationOptions creationOptions)
ParameterTypeDescription
nameStringThe name of the subfolder to add.
creationOptionsFolderCreationOptionsThe options for creating the subfolder.

Return Value

The FolderInfo representing the added subfolder.

Exceptions

exceptioncondition
NotImplementedExceptionthrows, if a PST file version is ANSI.
ArgumentNullExceptionthrows, if a subfolder name is null or empty.
InvalidOperationExceptionthrows, if a PST is open for reading only.
InvalidOperationExceptionthrows, if a folder with same name already exists. Whether folders have the same name will depend on the AllowNameCaseDifference parameter.

Remarks

name can be a path with backslash separators, such as Parent1\Parent2\Subfolder; set FolderCreationOptions.CreateHierarchy to create the parent folders that do not exist yet. Whether a folder with the same name already exists depends on FolderCreationOptions.AllowNameCaseDifference: when it is false (the default), names are compared case-insensitively and an existing name throws InvalidOperationException; when it is true, a name that differs only in case creates a new folder.

Examples

This example creates a folder three levels deep, adding the parent folders that are missing.

[C#]

using (var pst = PersonalStorage.FromFile("archive.pst"))
{
    // Treat the name as a path and create the folders that do not exist yet
    var options = new FolderCreationOptions { CreateHierarchy = true };

    var folder = pst.RootFolder.AddSubFolder(@"Projects\2026\Reports", options);
    Console.WriteLine($"Created {folder.DisplayName}");
}

[Visual Basic]

Using pst As PersonalStorage = PersonalStorage.FromFile("archive.pst")
    ' Treat the name as a path and create the folders that do not exist yet
    Dim options As New FolderCreationOptions With {.CreateHierarchy = True}

    Dim folder As FolderInfo = pst.RootFolder.AddSubFolder("Projects\2026\Reports", options)
    Console.WriteLine($"Created {folder.DisplayName}")
End Using

See Also