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
stringThe name of this library
sourceKnownFolder
IKnownFolderThe known folder
overwrite
boolOverride 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
stringThe name of this library
overwrite
boolAllow 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
stringThe name of this library
folderPath
stringThe path to the local folder
overwrite
boolOverride an existing library with the same name
Properties
Count
The count of the items in the list.
public int Count { get; }
Property Value
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
IconResourceId
The Resource Reference to the icon.
public IconReference IconResourceId { get; set; }
Property Value
IsPinnedToNavigationPane
Whether the library will be pinned to the Explorer Navigation Pane
public bool IsPinnedToNavigationPane { get; set; }
Property Value
IsPlatformSupported
Indicates whether this feature is supported on the current platform.
public static bool IsPlatformSupported { get; }
Property Value
IsReadOnly
Indicates whether this list is read-only or not.
public bool IsReadOnly { get; }
Property Value
this[int]
Retrieves the folder at the specified index
public ShellFileSystemFolder this[int index] { get; set; }
Parameters
index
intThe 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
LibraryType
One of predefined Library types
public LibraryFolderType LibraryType { get; set; }
Property Value
Exceptions
- COMException
Will throw if no Library Type is set
LibraryTypeId
The Guid of the Library type
public Guid LibraryTypeId { get; }
Property Value
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
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
ShellFileSystemFolderThe folder to add to the library.
Add(string)
Add an existing folder to this library
public void Add(string folderPath)
Parameters
folderPath
stringThe 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
ShellFileSystemFolderThe 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
stringThe 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
boolIndicates 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
ShellFileSystemFolderThe 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
IKnownFolderA known folder.
isReadOnly
boolIf 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
stringThe name of the library
isReadOnly
boolIf 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
stringThe name of the library.
folderPath
stringThe path to the library.
isReadOnly
boolIf 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
ShellFileSystemFolderThe 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
stringThe 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
IKnownFolderA known folder.
windowHandle
nintThe parent window,or IntPtr.Zero for no parent
title
stringA title for the library management dialog, or null to use the library name as the title
instruction
stringAn optional help string to display for the library management dialog
allowAllLocations
boolIf 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
stringThe name of the library
windowHandle
nintThe parent window,or IntPtr.Zero for no parent
title
stringA title for the library management dialog, or null to use the library name as the title
instruction
stringAn optional help string to display for the library management dialog
allowAllLocations
boolIf 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
stringThe name of the library
folderPath
stringThe path to the library.
windowHandle
nintThe parent window,or IntPtr.Zero for no parent
title
stringA title for the library management dialog, or null to use the library name as the title
instruction
stringAn optional help string to display for the library management dialog
allowAllLocations
boolIf 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.