static void Main(string[] args) { string libraryName = "All-In-One Code Framework"; ///////////////////////////////////////////////////////////////////// // Create a shell library. // Console.WriteLine("Create shell library: {0}", libraryName); using (ShellLibrary library = new ShellLibrary(libraryName, true)) { } Console.WriteLine("Press ENTER to continue..."); Console.ReadLine(); ///////////////////////////////////////////////////////////////////// // Show Manage Library UI. // Console.WriteLine("Show Manage Library UI"); // ShowManageLibraryUI requires that the library is not currently // opened with write permission. ShellLibrary.ShowManageLibraryUI(libraryName, IntPtr.Zero, "CSWin7ShellLibrary", "Manage Library folders and settings", true); Console.WriteLine("Press ENTER to continue..."); Console.ReadLine(); // Open the shell libary Console.WriteLine("Open shell library: {0}", libraryName); using (ShellLibrary library = ShellLibrary.Load(libraryName, false)) { ///////////////////////////////////////////////////////////////// // Add a folder to the shell library. // Console.WriteLine("Add a folder to the shell library"); string folderPath; // Display common dialog for selecting the folder to be added CommonOpenFileDialog fileDlg = new CommonOpenFileDialog(); fileDlg.IsFolderPicker = true; if (fileDlg.ShowDialog() == CommonFileDialogResult.Cancel) { return; } folderPath = fileDlg.FileName; Console.WriteLine("The selected folder is {0}", folderPath); // Add the folder to the shell library library.Add(folderPath); library.DefaultSaveFolder = folderPath; Console.WriteLine("Press ENTER to continue..."); Console.ReadLine(); ///////////////////////////////////////////////////////////////// // List all folders in the library. // Console.WriteLine("List all folders in the library"); foreach (ShellFolder folder in library) { Console.WriteLine(folder); } Console.WriteLine("Press ENTER to continue..."); Console.ReadLine(); ///////////////////////////////////////////////////////////////// // Remove a folder from the shell library. // Console.WriteLine("Remove a folder from the shell library"); library.Remove(folderPath); Console.WriteLine("Press ENTER to continue..."); Console.ReadLine(); } ///////////////////////////////////////////////////////////////////// // Delete the shell library. // Console.WriteLine("Delete the shell library"); string librariesPath = Path.Combine(Environment.GetFolderPath( Environment.SpecialFolder.ApplicationData), ShellLibrary.LibrariesKnownFolder.RelativePath); string libraryPath = Path.Combine(librariesPath, libraryName); string libraryFullPath = Path.ChangeExtension(libraryPath, "library-ms"); File.Delete(libraryFullPath); }
public static void ManageUI(string name) { ShellLibrary.ShowManageLibraryUI(ShellLibrary.CreateLibraryFullName(name), IntPtr.Zero, null, null, true); }
/// <summary> /// Show the explorer library manage user interface /// </summary> /// <param name="hOwnerWnd">the parent window handle</param> public void OpenLibraryManageUI(IntPtr hOwnerWnd) { ShellLibrary.ShowManageLibraryUI(LibraryName, hOwnerWnd, "The Windows Shell Explorer Library Manager", "Manage the " + LibraryName, true); }