/// <summary> /// Adds a location (folder, library, search connector, known folder) to the list of /// places available for the user to open or save items. This method actually adds an item /// to the <b>Favorite Links</b> or <b>Places</b> section of the Open/Save dialog. Overload method /// takes in a string for the path. /// </summary> /// <param name="path">The item to add to the places list.</param> /// <param name="location">One of the enumeration values that indicates placement of the item in the list.</param> public void AddPlace(string path, FileDialogAddPlaceLocation location) { if (string.IsNullOrEmpty(path)) { throw new ArgumentNullException("path"); } // Get our native dialog if (nativeDialog == null) { InitializeNativeFileDialog(); nativeDialog = GetNativeFileDialog(); } // Create a native shellitem from our path IShellItem2 nativeShellItem; Guid guid = new Guid(ShellIIDGuid.IShellItem2); int retCode = ShellNativeMethods.SHCreateItemFromParsingName(path, IntPtr.Zero, ref guid, out nativeShellItem); if (!CoreErrorHelper.Succeeded(retCode)) { throw new Exception(LocalizedMessages.CommonFileDialogCannotCreateShellItem, Marshal.GetExceptionForHR(retCode)); } // Add the shellitem to the places list if (nativeDialog != null) { nativeDialog.AddPlace(nativeShellItem, (ShellNativeMethods.FileDialogAddPlacement)location); } }
public void AddPlace(string path, FileDialogAddPlaceLocation location) { Contract.Requires <ArgumentException>(!String.IsNullOrWhiteSpace(path)); if (this.FileDialogNative != null) { var shellItem = ShellItem.FromParsingName(path); this.FileDialogNative.AddPlace(shellItem.ShellItemInterface, (FDAP)location); } }
/// <summary> /// Adds a location, such as a folder, library, search connector, or known folder, to the list of /// places available for a user to open or save items. This method actually adds an item /// to the <b>Favorite Links</b> or <b>Places</b> section of the Open/Save dialog. /// </summary> /// <param name="place">The item to add to the places list.</param> /// <param name="location">One of the enumeration values that indicates placement of the item in the list.</param> public void AddPlace(ShellContainer place, FileDialogAddPlaceLocation location) { if (place == null) { throw new ArgumentNullException("place"); } // Get our native dialog if (nativeDialog == null) { InitializeNativeFileDialog(); nativeDialog = GetNativeFileDialog(); } // Add the shellitem to the places list if (nativeDialog != null) { nativeDialog.AddPlace(place.NativeShellItem, (ShellNativeMethods.FileDialogAddPlacement)location); } }
/// <summary> /// Add a path to the specified location. /// </summary> /// <param name="path"></param> /// <param name="location"></param> public void AddPlace(string path, FileDialogAddPlaceLocation location) { Contract.Requires <ArgumentNullException>(!String.IsNullOrWhiteSpace(path)); this.FileDialogInternal.AddPlace(path, location); }
/// <summary> /// Add a folder to the specified location. /// </summary> /// <param name="place"></param> /// <param name="location"></param> public void AddPlace(ShellFolder place, FileDialogAddPlaceLocation location) { Contract.Requires <ArgumentNullException>(place != null); this.FileDialogInternal.AddPlace(place, location); }
/// <summary> /// Adds a location (folder, library, search connector, known folder) to the list of /// places available for the user to open or save items. This method actually adds an item /// to the <b>Favorite Links</b> or <b>Places</b> section of the Open/Save dialog. Overload method /// takes in a string for the path. /// </summary> /// <param name="path">The item to add to the places list.</param> /// <param name="location">One of the enumeration values that indicates placement of the item in the list.</param> public void AddPlace(string path, FileDialogAddPlaceLocation location) { if (string.IsNullOrEmpty(path)) { throw new ArgumentNullException("path"); } // Get our native dialog if (nativeDialog == null) { InitializeNativeFileDialog(); nativeDialog = GetNativeFileDialog(); } // Create a native shellitem from our path IShellItem2 nativeShellItem; Guid guid = new Guid(ShellIIDGuid.IShellItem2); int retCode = ShellNativeMethods.SHCreateItemFromParsingName(path, IntPtr.Zero, ref guid, out nativeShellItem); if (!CoreErrorHelper.Succeeded(retCode)) { throw new CommonControlException(LocalizedMessages.CommonFileDialogCannotCreateShellItem, Marshal.GetExceptionForHR(retCode)); } // Add the shellitem to the places list if (nativeDialog != null) { nativeDialog.AddPlace(nativeShellItem, (ShellNativeMethods.FileDialogAddPlacement)location); } }
/// <summary> /// Adds a location, such as a folder, library, search connector, or known folder, to the list of /// places available for a user to open or save items. This method actually adds an item /// to the <b>Favorite Links</b> or <b>Places</b> section of the Open/Save dialog. /// </summary> /// <param name="place">The item to add to the places list.</param> /// <param name="location">One of the enumeration values that indicates placement of the item in the list.</param> public void AddPlace(ShellContainer place, FileDialogAddPlaceLocation location) { // Get our native dialog if (nativeDialog == null) { InitializeNativeFileDialog(); nativeDialog = GetNativeFileDialog(); } // Add the shellitem to the places list if (nativeDialog != null) nativeDialog.AddPlace(((ShellObject)place).NativeShellItem, (ShellNativeMethods.FDAP)location); }
public void AddPlace(ShellFolder place, FileDialogAddPlaceLocation location) { this.FileDialogNative?.AddPlace(place.ShellItem.ShellItemInterface, (FDAP)location); }
/// <summary> /// Adds a location (folder, library, search connector, known folder) to the list of /// places available for the user to open or save items. This method actually adds an item /// to the <b>Favorite Links</b> or <b>Places</b> section of the Open/Save dialog. Overload method /// takes in a string for the path. /// </summary> /// <param name="path">The item to add to the places list.</param> /// <param name="location">One of the enumeration values that indicates placement of the item in the list.</param> public void AddPlace(string path, FileDialogAddPlaceLocation location) { if (string.IsNullOrEmpty(path)) { throw new ArgumentNullException("path"); } // Get our native dialog if (nativeDialog == null) { InitializeNativeFileDialog(); nativeDialog = GetNativeFileDialog(); } // Create a native shellitem from our path IShellItem2 nativeShellItem; Guid guid = new Guid(ShellIIDGuid.IShellItem2); int retCode = ShellNativeMethods.SHCreateItemFromParsingName(path, IntPtr.Zero, ref guid, out nativeShellItem); // Add the shellitem to the places list if (nativeDialog != null) { nativeDialog.AddPlace(nativeShellItem, (ShellNativeMethods.FileDialogAddPlacement)location); } }