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
- FlatButtonAppearance.cs
- FactoryGenerator.cs
- Encoder.cs
- URLAttribute.cs
- ClientApiGenerator.cs
- X509Utils.cs
- XmlException.cs
- FormsAuthenticationConfiguration.cs
- SqlParameter.cs
- Metadata.cs
- QueueProcessor.cs
- DetailsViewUpdatedEventArgs.cs
- EditingMode.cs
- While.cs
- XmlValueConverter.cs
- DocumentReference.cs
- SiteMapNodeCollection.cs
- bidPrivateBase.cs
- RoutingChannelExtension.cs
- EnterpriseServicesHelper.cs
- Profiler.cs
- Command.cs
- VectorAnimation.cs
- WebHttpSecurityElement.cs
- RelationshipDetailsRow.cs
- DiffuseMaterial.cs
- InertiaRotationBehavior.cs
- ServiceDescription.cs
- BinaryObjectInfo.cs
- HandleInitializationContext.cs
- ResourceBinder.cs
- ToolboxItem.cs
- CustomLineCap.cs
- unitconverter.cs
- MouseDevice.cs
- TemplateParser.cs
- datacache.cs
- InvalidComObjectException.cs
- TextEditorCharacters.cs
- DiagnosticsConfiguration.cs
- DataGridViewCellLinkedList.cs
- ClipboardData.cs
- UInt64.cs
- FixedSOMTableRow.cs
- Validator.cs
- EntityKeyElement.cs
- SchemaEntity.cs
- AtlasWeb.Designer.cs
- GPPOINTF.cs
- Aggregates.cs
- InfoCardSymmetricAlgorithm.cs
- XomlSerializationHelpers.cs
- ComponentChangingEvent.cs
- FocusChangedEventArgs.cs
- Misc.cs
- SecurityContextTokenCache.cs
- EntityDataSourceQueryBuilder.cs
- DataProtection.cs
- HeaderCollection.cs
- PageParser.cs
- StrokeNodeOperations.cs
- BasicHttpSecurityElement.cs
- PermissionSetTriple.cs
- JsonFaultDetail.cs
- BamlTreeMap.cs
- BindStream.cs
- ChameleonKey.cs
- ImageFormatConverter.cs
- ResourceKey.cs
- PolicyVersion.cs
- ContainerSelectorBehavior.cs
- ScriptMethodAttribute.cs
- UndoEngine.cs
- JoinSymbol.cs
- BuildResultCache.cs
- ModuleBuilderData.cs
- ClusterSafeNativeMethods.cs
- MetroSerializationManager.cs
- PolyQuadraticBezierSegment.cs
- ProcessExitedException.cs
- ListViewDeletedEventArgs.cs
- StrokeNodeOperations.cs
- Rotation3DKeyFrameCollection.cs
- TaskFormBase.cs
- LZCodec.cs
- ControlBuilderAttribute.cs
- TableTextElementCollectionInternal.cs
- HtmlButton.cs
- EditorZoneBase.cs
- PhonemeEventArgs.cs
- MoveSizeWinEventHandler.cs
- UrlMappingCollection.cs
- OleDbSchemaGuid.cs
- NetworkInterface.cs
- ResourceReferenceExpression.cs
- MemberNameValidator.cs
- ExceptionHelpers.cs
- HttpCachePolicy.cs
- VisualStyleRenderer.cs
- RenderingEventArgs.cs