/// <summary> /// Create a new instance of a <see cref="ShellFolder" /> derived class /// that best matches the nature of the specified <see cref="ShellItem" />. /// </summary> /// <param name="shellItem"><see cref="ShellItem" />.</param> /// <returns>Created a new instance of <see cref="ShellFolder" /> derived class.</returns> private static ShellFolder CreateFolder(ShellItem shellItem) { Contract.Requires(shellItem != null); var shellLibrary = ShellLibraryFactory.FromShellItem(shellItem, true); if (SameItemType(shellItem.GetItemType(), ShellLibraryFactory.FileExtension) && (shellLibrary != null)) { // Library return(shellLibrary); } else if (SameItemType(shellItem, ShellSearchConnector.FileExtension)) { // Search connector return(new ShellSearchConnector(shellItem)); } else if (SameItemType(shellItem, ShellSavedSearchCollection.FileExtension)) { // Saved search collection return(new ShellSavedSearchCollection(shellItem)); } else { var knownFolderNative = GetKnownFolderNative(shellItem); if (knownFolderNative != null) { // Known folder return(new ShellKnownFolder(shellItem, knownFolderNative)); } } // Folder return(new ShellFolder(shellItem)); }
public async Task LoadKnownFolderTest() { await STATask.Run(() => { var actual = ShellLibraryFactory.Load(ShellKnownFolderFactory.FromCanonicalName("PicturesLibrary")); Assert.NotNull(actual); Assert.Equal(LibraryFolderTypes.Pictures, actual.LibraryType); Dump(actual); }); }