/// <summary> /// Creates a shell library in the Libraries Known Folder, /// using the given shell library name. /// </summary> /// <param name="libraryName">The name of this library</param> /// <param name="overwrite">Allow overwriting an existing library; if one exists with the same name</param> public ShellLibrary(string libraryName, bool overwrite) : this() { if (string.IsNullOrEmpty(libraryName)) { throw new ArgumentException("Library Name Empty!", "libraryName"); } this.Name = libraryName; var guid = new Guid(InterfaceGuids.Libraries); var flags = overwrite ? LibrarySaveOptions.OverrideExisting : LibrarySaveOptions.FailIfThere; nativeShellLibrary = (INativeShellLibrary) new ShellLibraryCoClass(); nativeShellLibrary.SaveInKnownFolder(ref guid, libraryName, flags, out m_ComInterface); }
/// <summary> /// Creates a shell library in the Libraries Known Folder, /// using the given shell library name. /// </summary> /// <param name="libraryName">The name of this library</param> /// <param name="overwrite">Allow overwriting an existing library; if one exists with the same name</param> public ShellLibrary(string libraryName, bool overwrite) : this() { if (string.IsNullOrEmpty(libraryName)) { throw new ArgumentException(LocalizedMessages.ShellLibraryEmptyName, "libraryName"); } Name = libraryName; Guid guid = new Guid(ShellKFIDGuid.Libraries); ShellNativeMethods.LibrarySaveOptions flags = overwrite ? ShellNativeMethods.LibrarySaveOptions.OverrideExisting : ShellNativeMethods.LibrarySaveOptions.FailIfThere; nativeShellLibrary = (INativeShellLibrary) new ShellLibraryCoClass(); nativeShellLibrary.SaveInKnownFolder(ref guid, libraryName, flags, out nativeShellItem); }
/// <summary> /// Creates a shell library in a given Known Folder, /// using the given shell library name. /// </summary> /// <param name="libraryName">The name of this library</param> /// <param name="sourceKnownFolder">The known folder</param> /// <param name="overwrite">Override an existing library with the same name</param> public ShellLibrary(string libraryName, IKnownFolder sourceKnownFolder, bool overwrite) : this() { if (string.IsNullOrEmpty(libraryName)) { throw new ArgumentException(LocalizedMessages.ShellLibraryEmptyName, "libraryName"); } knownFolder = sourceKnownFolder; this.Name = libraryName; Guid guid = knownFolder.FolderId; LibrarySaveOptions flags = overwrite ? LibrarySaveOptions.OverrideExisting : LibrarySaveOptions.FailIfThere; nativeShellLibrary = (INativeShellLibrary) new ShellLibraryCoClass(); nativeShellLibrary.SaveInKnownFolder(ref guid, libraryName, flags, out nativeShellItem); }
/// <summary> /// Creates a shell library in the Libraries Known Folder, /// using the given shell library name. /// </summary> /// <param name="libraryName">The name of this library</param> /// <param name="overwrite">Allow overwriting an existing library; if one exists with the same name</param> public ShellLibrary(string libraryName, bool overwrite) { CoreHelpers.ThrowIfNotWin7(); if (String.IsNullOrEmpty(libraryName)) { throw new ArgumentNullException("libraryName", "libraryName cannot be empty."); } this.Name = libraryName; Guid guid = new Guid(ShellKFIDGuid.Libraries); ShellNativeMethods.LIBRARYSAVEFLAGS flags = overwrite ? ShellNativeMethods.LIBRARYSAVEFLAGS.LSF_OVERRIDEEXISTING : ShellNativeMethods.LIBRARYSAVEFLAGS.LSF_FAILIFTHERE; nativeShellLibrary = (INativeShellLibrary) new ShellLibraryCoClass(); nativeShellLibrary.SaveInKnownFolder(ref guid, libraryName, flags, out nativeShellItem); }