Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / WinForms / Managed / System / WinForms / FileDialogCustomPlacesCollection.cs / 1305376 / 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) { //Walk backwards for (int i = this.Items.Count - 1; i >= 0; --i) { FileDialogCustomPlace customPlace = this.Items[i]; // Fix for Dev10 bug 536188: we need permission to check whether the specified path exists FileIOPermission permission = new FileIOPermission(FileIOPermissionAccess.PathDiscovery, customPlace.Path); permission.Demand(); 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) { //Walk backwards for (int i = this.Items.Count - 1; i >= 0; --i) { FileDialogCustomPlace customPlace = this.Items[i]; // Fix for Dev10 bug 536188: we need permission to check whether the specified path exists FileIOPermission permission = new FileIOPermission(FileIOPermissionAccess.PathDiscovery, customPlace.Path); permission.Demand(); 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
- BaseEntityWrapper.cs
- DataGridViewSelectedCellCollection.cs
- SqlConnection.cs
- ObjectStateEntry.cs
- Psha1DerivedKeyGenerator.cs
- Int16Storage.cs
- EventRouteFactory.cs
- List.cs
- MiniAssembly.cs
- ClientSettingsStore.cs
- FormsIdentity.cs
- RuleRef.cs
- PageEventArgs.cs
- StackOverflowException.cs
- DecimalConstantAttribute.cs
- PropertySourceInfo.cs
- InfoCardAsymmetricCrypto.cs
- arclist.cs
- ImageAttributes.cs
- HttpCacheVary.cs
- ProfileSettingsCollection.cs
- ReliabilityContractAttribute.cs
- BaseCodeDomTreeGenerator.cs
- OperationFormatUse.cs
- OfTypeExpression.cs
- wgx_commands.cs
- ClientEndpointLoader.cs
- PerformanceCountersElement.cs
- KeyNotFoundException.cs
- RotateTransform3D.cs
- ScalarType.cs
- CryptoHelper.cs
- QuaternionKeyFrameCollection.cs
- TextSerializer.cs
- Quad.cs
- ImageAttributes.cs
- graph.cs
- AttributeCollection.cs
- ValidationManager.cs
- CharAnimationUsingKeyFrames.cs
- TaiwanCalendar.cs
- ComboBox.cs
- BinaryReader.cs
- DesignerDataColumn.cs
- Utils.cs
- BrowserCapabilitiesFactory.cs
- followingsibling.cs
- WindowsGraphics2.cs
- ProcessProtocolHandler.cs
- RadioButtonBaseAdapter.cs
- Socket.cs
- ClosureBinding.cs
- FontClient.cs
- Sentence.cs
- SoapSchemaImporter.cs
- PersonalizationStateInfoCollection.cs
- SystemIPInterfaceProperties.cs
- ActivationArguments.cs
- DbConnectionStringCommon.cs
- CodeGenerator.cs
- ActivitySurrogateSelector.cs
- InfiniteIntConverter.cs
- SeparatorAutomationPeer.cs
- listitem.cs
- SrgsElementFactory.cs
- WebServiceTypeData.cs
- TypeElement.cs
- WindowsListView.cs
- XmlMtomWriter.cs
- ResourceDescriptionAttribute.cs
- StreamReader.cs
- EventLogEntry.cs
- DataBoundControlAdapter.cs
- PatternMatcher.cs
- MaterializeFromAtom.cs
- AddInBase.cs
- RoutedEventHandlerInfo.cs
- ProcessInfo.cs
- SafeCryptoHandles.cs
- XMLDiffLoader.cs
- ArgumentDesigner.xaml.cs
- TriggerAction.cs
- StatusBar.cs
- SystemIPv6InterfaceProperties.cs
- DataGridViewIntLinkedList.cs
- UInt64Storage.cs
- URLMembershipCondition.cs
- CodeAccessPermission.cs
- ColorConvertedBitmap.cs
- Base64Decoder.cs
- DataViewManagerListItemTypeDescriptor.cs
- SimpleApplicationHost.cs
- TemplateApplicationHelper.cs
- EncryptedHeader.cs
- Encoding.cs
- XmlAttributeCache.cs
- COM2IPerPropertyBrowsingHandler.cs
- WebBrowserSiteBase.cs
- FilteredAttributeCollection.cs
- RuleInfoComparer.cs