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
- KeyedCollection.cs
- cookiecontainer.cs
- TraceListener.cs
- ClientRuntimeConfig.cs
- FormViewUpdateEventArgs.cs
- ComponentResourceKeyConverter.cs
- NamespaceEmitter.cs
- OAVariantLib.cs
- XmlAtomicValue.cs
- FontFamilyValueSerializer.cs
- HttpModulesSection.cs
- UserControlCodeDomTreeGenerator.cs
- TreeViewBindingsEditor.cs
- XmlValueConverter.cs
- ExpressionBuilderContext.cs
- SymbolMethod.cs
- GridEntryCollection.cs
- ReflectionHelper.cs
- BuildManager.cs
- FormViewRow.cs
- LinqDataSourceContextData.cs
- Assembly.cs
- _Semaphore.cs
- PropertyMap.cs
- XmlEnumAttribute.cs
- TraceContextRecord.cs
- GeneralTransform3D.cs
- SettingsSavedEventArgs.cs
- Unit.cs
- TemplateComponentConnector.cs
- URLIdentityPermission.cs
- HtmlWindow.cs
- _OverlappedAsyncResult.cs
- SmtpNetworkElement.cs
- SmiXetterAccessMap.cs
- ScrollBar.cs
- nulltextnavigator.cs
- StringSource.cs
- ManifestSignedXml.cs
- ReferentialConstraint.cs
- ReferenceTypeElement.cs
- CustomGrammar.cs
- ServiceXNameTypeConverter.cs
- AnimationLayer.cs
- ElementAction.cs
- _ListenerRequestStream.cs
- StrongNamePublicKeyBlob.cs
- ExpressionReplacer.cs
- SortableBindingList.cs
- DataGrid.cs
- BookmarkScopeManager.cs
- _ConnectStream.cs
- TextEditorDragDrop.cs
- TextModifier.cs
- controlskin.cs
- Parsers.cs
- Wizard.cs
- MarshalByValueComponent.cs
- ToolStripDropDownButton.cs
- UriTemplateLiteralQueryValue.cs
- SimpleLine.cs
- UnsafeNativeMethods.cs
- DynamicPropertyReader.cs
- DynamicVirtualDiscoSearcher.cs
- Filter.cs
- NullRuntimeConfig.cs
- FlagsAttribute.cs
- CodeThrowExceptionStatement.cs
- GeometryConverter.cs
- RuntimeWrappedException.cs
- GridViewRowPresenterBase.cs
- ImageList.cs
- PaginationProgressEventArgs.cs
- TextSerializer.cs
- GenericIdentity.cs
- DateTimeOffsetStorage.cs
- ExceptionValidationRule.cs
- HttpConfigurationContext.cs
- XamlStyleSerializer.cs
- XmlHierarchicalEnumerable.cs
- Point3DKeyFrameCollection.cs
- SpellerHighlightLayer.cs
- XpsPackagingException.cs
- EdmComplexTypeAttribute.cs
- AnimationLayer.cs
- GenericIdentity.cs
- CssTextWriter.cs
- TemplateBindingExpressionConverter.cs
- SecurityDescriptor.cs
- _Events.cs
- PageContentCollection.cs
- ToolStripCodeDomSerializer.cs
- ObjectStateFormatter.cs
- FloatMinMaxAggregationOperator.cs
- OleDbDataReader.cs
- Attachment.cs
- PostBackTrigger.cs
- AnnotationAdorner.cs
- CommandField.cs
- ExpressionList.cs