Table of Contents

Class ShellLibrary

Namespace
Microsoft.WindowsAPICodePack.Shell
Assembly
Microsoft.WindowsAPICodePack.Shell.dll

A Shell Library in the Shell Namespace

public sealed class ShellLibrary : ShellContainer, IEquatable<ShellObject>, IEnumerable<ShellObject>, IDisposable, IList<ShellFileSystemFolder>, ICollection<ShellFileSystemFolder>, IEnumerable<ShellFileSystemFolder>, IEnumerable
Inheritance
ShellLibrary
Implements
Inherited Members

Constructors

ShellLibrary(string, IKnownFolder, bool)

Creates a shell library in a given Known Folder, using the given shell library name.

public ShellLibrary(string libraryName, IKnownFolder sourceKnownFolder, bool overwrite)

Parameters

libraryName string

The name of this library

sourceKnownFolder IKnownFolder

The known folder

overwrite bool

Override an existing library with the same name

ShellLibrary(string, bool)

Creates a shell library in the Libraries Known Folder, using the given shell library name.

public ShellLibrary(string libraryName, bool overwrite)

Parameters

libraryName string

The name of this library

overwrite bool

Allow overwriting an existing library; if one exists with the same name

ShellLibrary(string, string, bool)

Creates a shell library in a given local folder, using the given shell library name.

public ShellLibrary(string libraryName, string folderPath, bool overwrite)

Parameters

libraryName string

The name of this library

folderPath string

The path to the local folder

overwrite bool

Override an existing library with the same name

Properties

Count

The count of the items in the list.

public int Count { get; }

Property Value

int

DefaultSaveFolder

By default, this folder is the first location added to the library. The default save folder is both the default folder where files can be saved, and also where the library XML file will be saved, if no other path is specified

public string DefaultSaveFolder { get; set; }

Property Value

string

IconResourceId

The Resource Reference to the icon.

public IconReference IconResourceId { get; set; }

Property Value

IconReference

IsPinnedToNavigationPane

Whether the library will be pinned to the Explorer Navigation Pane

public bool IsPinnedToNavigationPane { get; set; }

Property Value

bool

IsPlatformSupported

Indicates whether this feature is supported on the current platform.

public static bool IsPlatformSupported { get; }

Property Value

bool

IsReadOnly

Indicates whether this list is read-only or not.

public bool IsReadOnly { get; }

Property Value

bool

this[int]

Retrieves the folder at the specified index

public ShellFileSystemFolder this[int index] { get; set; }

Parameters

index int

The index of the folder to retrieve.

Property Value

ShellFileSystemFolder

A folder.

LibrariesKnownFolder

Get a the known folder FOLDERID_Libraries

public static IKnownFolder LibrariesKnownFolder { get; }

Property Value

IKnownFolder

LibraryType

One of predefined Library types

public LibraryFolderType LibraryType { get; set; }

Property Value

LibraryFolderType

Exceptions

COMException

Will throw if no Library Type is set

LibraryTypeId

The Guid of the Library type

public Guid LibraryTypeId { get; }

Property Value

Guid

Exceptions

COMException

Will throw if no Library Type is set

Name

The name of the library, every library must have a name

public override string Name { get; }

Property Value

string

Exceptions

COMException

Will throw if no Icon is set

Methods

Add(ShellFileSystemFolder)

Add a new FileSystemFolder or SearchConnector

public void Add(ShellFileSystemFolder item)

Parameters

item ShellFileSystemFolder

The folder to add to the library.

Add(string)

Add an existing folder to this library

public void Add(string folderPath)

Parameters

folderPath string

The path to the folder to be added to the library.

Clear()

Clear all items of this Library

public void Clear()

Close()

Close the library, and release its associated file system resources

public void Close()

Contains(ShellFileSystemFolder)

Determines if a folder exists in the collection.

public bool Contains(ShellFileSystemFolder item)

Parameters

item ShellFileSystemFolder

The folder.

Returns

bool

true, if the folder exists in the collection.

Contains(string)

Determines if an item with the specified path exists in the collection.

public bool Contains(string fullPath)

Parameters

fullPath string

The path of the item.

Returns

bool

true if the item exists in the collection.

Dispose(bool)

Release resources

protected override void Dispose(bool disposing)

Parameters

disposing bool

Indicates that this was called from Dispose(), rather than from the finalizer.

~ShellLibrary()

Release resources

protected ~ShellLibrary()

GetEnumerator()

Retrieves the collection enumerator.

public IEnumerator<ShellFileSystemFolder> GetEnumerator()

Returns

IEnumerator<ShellFileSystemFolder>

The enumerator.

IndexOf(ShellFileSystemFolder)

Searches for the specified FileSystemFolder and returns the zero-based index of the first occurrence within Library list.

public int IndexOf(ShellFileSystemFolder item)

Parameters

item ShellFileSystemFolder

The item to search for.

Returns

int

The index of the item in the collection, or -1 if the item does not exist.

Load(IKnownFolder, bool)

Load the library using a number of options

public static ShellLibrary Load(IKnownFolder sourceKnownFolder, bool isReadOnly)

Parameters

sourceKnownFolder IKnownFolder

A known folder.

isReadOnly bool

If true, opens the library in read-only mode.

Returns

ShellLibrary

A ShellLibrary Object

Load(string, bool)

Load the library using a number of options

public static ShellLibrary Load(string libraryName, bool isReadOnly)

Parameters

libraryName string

The name of the library

isReadOnly bool

If true, loads the library in read-only mode.

Returns

ShellLibrary

A ShellLibrary Object

Load(string, string, bool)

Load the library using a number of options

public static ShellLibrary Load(string libraryName, string folderPath, bool isReadOnly)

Parameters

libraryName string

The name of the library.

folderPath string

The path to the library.

isReadOnly bool

If true, opens the library in read-only mode.

Returns

ShellLibrary

A ShellLibrary Object

Remove(ShellFileSystemFolder)

Remove a folder or search connector

public bool Remove(ShellFileSystemFolder item)

Parameters

item ShellFileSystemFolder

The item to remove.

Returns

bool

true if the item was removed.

Remove(string)

Remove a folder or search connector

public bool Remove(string folderPath)

Parameters

folderPath string

The path of the item to remove.

Returns

bool

true if the item was removed.

ShowManageLibraryUI(IKnownFolder, nint, string, string, bool)

Shows the library management dialog which enables users to mange the library folders and default save location.

public static void ShowManageLibraryUI(IKnownFolder sourceKnownFolder, nint windowHandle, string title, string instruction, bool allowAllLocations)

Parameters

sourceKnownFolder IKnownFolder

A known folder.

windowHandle nint

The parent window,or IntPtr.Zero for no parent

title string

A title for the library management dialog, or null to use the library name as the title

instruction string

An optional help string to display for the library management dialog

allowAllLocations bool

If true, do not show warning dialogs about locations that cannot be indexed

Remarks

If the library is already open in read-write mode, the dialog will not save the changes.

ShowManageLibraryUI(string, nint, string, string, bool)

Shows the library management dialog which enables users to mange the library folders and default save location.

public static void ShowManageLibraryUI(string libraryName, nint windowHandle, string title, string instruction, bool allowAllLocations)

Parameters

libraryName string

The name of the library

windowHandle nint

The parent window,or IntPtr.Zero for no parent

title string

A title for the library management dialog, or null to use the library name as the title

instruction string

An optional help string to display for the library management dialog

allowAllLocations bool

If true, do not show warning dialogs about locations that cannot be indexed

Remarks

If the library is already open in read-write mode, the dialog will not save the changes.

ShowManageLibraryUI(string, string, nint, string, string, bool)

Shows the library management dialog which enables users to mange the library folders and default save location.

public static void ShowManageLibraryUI(string libraryName, string folderPath, nint windowHandle, string title, string instruction, bool allowAllLocations)

Parameters

libraryName string

The name of the library

folderPath string

The path to the library.

windowHandle nint

The parent window,or IntPtr.Zero for no parent

title string

A title for the library management dialog, or null to use the library name as the title

instruction string

An optional help string to display for the library management dialog

allowAllLocations bool

If true, do not show warning dialogs about locations that cannot be indexed

Remarks

If the library is already open in read-write mode, the dialog will not save the changes.