Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / WinForms / Managed / System / WinForms / FileDialogCustomPlacesCollection.cs / 1 / FileDialogCustomPlacesCollection.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- using System; using System.Collections.ObjectModel; using System.IO; using System.Security; using System.Security.Permissions; namespace System.Windows.Forms { public class FileDialogCustomPlacesCollection : Collection{ internal void Apply(FileDialogNative.IFileDialog dialog) { //Assert FileIOPermission for getting the paths for the favorites new FileIOPermission(PermissionState.Unrestricted).Assert(); //Walk backwards for (int i = this.Items.Count - 1; i >= 0; --i) { FileDialogCustomPlace customPlace = this.Items[i]; try { FileDialogNative.IShellItem shellItem = customPlace.GetNativePath(); if (null != shellItem) { dialog.AddPlace(shellItem, 0); } } catch (FileNotFoundException) { } //Silently absorb FileNotFound exceptions (these could be caused by a path that disappeared after the place was added to the dialog). } } public void Add(string path) { Add(new FileDialogCustomPlace(path)); } public void Add(Guid knownFolderGuid) { Add(new FileDialogCustomPlace(knownFolderGuid)); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- using System; using System.Collections.ObjectModel; using System.IO; using System.Security; using System.Security.Permissions; namespace System.Windows.Forms { public class FileDialogCustomPlacesCollection : Collection{ internal void Apply(FileDialogNative.IFileDialog dialog) { //Assert FileIOPermission for getting the paths for the favorites new FileIOPermission(PermissionState.Unrestricted).Assert(); //Walk backwards for (int i = this.Items.Count - 1; i >= 0; --i) { FileDialogCustomPlace customPlace = this.Items[i]; try { FileDialogNative.IShellItem shellItem = customPlace.GetNativePath(); if (null != shellItem) { dialog.AddPlace(shellItem, 0); } } catch (FileNotFoundException) { } //Silently absorb FileNotFound exceptions (these could be caused by a path that disappeared after the place was added to the dialog). } } public void Add(string path) { Add(new FileDialogCustomPlace(path)); } public void Add(Guid knownFolderGuid) { Add(new FileDialogCustomPlace(knownFolderGuid)); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TransactionTraceIdentifier.cs
- PropertyItem.cs
- TypeDescriptorFilterService.cs
- ListViewItemEventArgs.cs
- ReadOnlyHierarchicalDataSourceView.cs
- UserControlBuildProvider.cs
- SettingsSavedEventArgs.cs
- safelink.cs
- Screen.cs
- WebPartsPersonalization.cs
- HtmlForm.cs
- PopupEventArgs.cs
- Pair.cs
- ToolBar.cs
- ScriptControlDescriptor.cs
- PersonalizationStateInfoCollection.cs
- DataGridViewCheckBoxColumn.cs
- HandoffBehavior.cs
- DisplayInformation.cs
- XmlAttributeCache.cs
- Native.cs
- ReturnEventArgs.cs
- _DisconnectOverlappedAsyncResult.cs
- TextElementEnumerator.cs
- Grid.cs
- InputBindingCollection.cs
- DataGridItemCollection.cs
- PeerNameRecord.cs
- XhtmlTextWriter.cs
- ExtensionFile.cs
- MemberMaps.cs
- safemediahandle.cs
- ToolBar.cs
- BoundsDrawingContextWalker.cs
- FunctionQuery.cs
- ApplicationId.cs
- Axis.cs
- CalendarDesigner.cs
- WebSysDescriptionAttribute.cs
- SqlParameterizer.cs
- AbstractDataSvcMapFileLoader.cs
- StringDictionaryWithComparer.cs
- ChtmlPhoneCallAdapter.cs
- BeginSelectCardRequest.cs
- ObjectDataSourceMethodEventArgs.cs
- SizeAnimationUsingKeyFrames.cs
- GraphicsState.cs
- DockPattern.cs
- TempFiles.cs
- ComponentSerializationService.cs
- TemplateXamlParser.cs
- ReferentialConstraint.cs
- IPPacketInformation.cs
- WebPartMenu.cs
- UserPersonalizationStateInfo.cs
- TableCell.cs
- IndexedString.cs
- Track.cs
- PreApplicationStartMethodAttribute.cs
- WebConfigurationManager.cs
- HtmlEmptyTagControlBuilder.cs
- VisualTreeFlattener.cs
- FontFamilyIdentifier.cs
- NetworkAddressChange.cs
- ListViewGroupConverter.cs
- TraceSection.cs
- XamlDebuggerXmlReader.cs
- DiscoveryDefaults.cs
- AddInDeploymentState.cs
- LocatorManager.cs
- QuestionEventArgs.cs
- wgx_render.cs
- MarshalByRefObject.cs
- unitconverter.cs
- Button.cs
- ProfessionalColorTable.cs
- CodeConstructor.cs
- ImageListImage.cs
- Char.cs
- WindowsStreamSecurityBindingElement.cs
- DataGridViewTextBoxCell.cs
- WebBrowserContainer.cs
- PermissionAttributes.cs
- DefaultValueAttribute.cs
- HttpValueCollection.cs
- WebPartCloseVerb.cs
- XmlStringTable.cs
- ObjectIDGenerator.cs
- HtmlTextArea.cs
- RecordBuilder.cs
- TypeDelegator.cs
- BufferModesCollection.cs
- ColumnProvider.cs
- SingleAnimationBase.cs
- ScrollProviderWrapper.cs
- PeerToPeerException.cs
- ButtonBase.cs
- SqlConnectionManager.cs
- ColorPalette.cs
- FileLoadException.cs