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
- StyleHelper.cs
- DesignerObjectListAdapter.cs
- MultipartIdentifier.cs
- XmlIlTypeHelper.cs
- BCryptHashAlgorithm.cs
- MultiSelectRootGridEntry.cs
- XmlJsonReader.cs
- DocumentViewer.cs
- ToolStripTemplateNode.cs
- OperationInfo.cs
- TemplateControl.cs
- SecurityToken.cs
- KeyGestureValueSerializer.cs
- SimpleLine.cs
- ContentValidator.cs
- datacache.cs
- ScrollEvent.cs
- HitTestParameters.cs
- HttpPostedFile.cs
- ButtonFieldBase.cs
- IntegerValidator.cs
- Timer.cs
- InternalBufferManager.cs
- WebResourceAttribute.cs
- SizeF.cs
- ValidatedControlConverter.cs
- WindowProviderWrapper.cs
- RuntimeWrappedException.cs
- MultiTrigger.cs
- WorkflowMarkupSerializerMapping.cs
- Asn1IntegerConverter.cs
- DecoderExceptionFallback.cs
- StreamingContext.cs
- HtmlInputButton.cs
- WsatTransactionFormatter.cs
- WSFederationHttpBindingCollectionElement.cs
- ParameterRetriever.cs
- SafeTimerHandle.cs
- WebPartTransformerAttribute.cs
- MeasureData.cs
- HexParser.cs
- AudioFormatConverter.cs
- PrintDialog.cs
- DynamicRendererThreadManager.cs
- DefaultBinder.cs
- DataGridViewIntLinkedList.cs
- OpCopier.cs
- DataSetViewSchema.cs
- ContainerControl.cs
- Int64KeyFrameCollection.cs
- DefaultMemberAttribute.cs
- RootBuilder.cs
- TakeOrSkipQueryOperator.cs
- CodeThrowExceptionStatement.cs
- ExpressionPrefixAttribute.cs
- BuildProvidersCompiler.cs
- Attributes.cs
- DataTableNewRowEvent.cs
- AddInControllerImpl.cs
- UDPClient.cs
- TextBreakpoint.cs
- EllipticalNodeOperations.cs
- PropertyMapper.cs
- Expander.cs
- CacheMemory.cs
- PropertiesTab.cs
- HttpHandlersSection.cs
- Win32PrintDialog.cs
- HiddenField.cs
- TraceContext.cs
- TreeViewCancelEvent.cs
- ActivityWithResultWrapper.cs
- DateTimePickerDesigner.cs
- InOutArgument.cs
- MetadataCache.cs
- ConfigurationSection.cs
- ScriptRef.cs
- FileUpload.cs
- MenuItemStyle.cs
- ListViewInsertionMark.cs
- Buffer.cs
- RegexRunner.cs
- translator.cs
- ImmutableDispatchRuntime.cs
- Attribute.cs
- Metadata.cs
- MultiTrigger.cs
- ScriptIgnoreAttribute.cs
- AttachedAnnotation.cs
- SmtpFailedRecipientsException.cs
- XmlSchemaObjectCollection.cs
- DateTimeSerializationSection.cs
- CodeGenerator.cs
- Control.cs
- TextReturnReader.cs
- SplitterCancelEvent.cs
- RemotingConfiguration.cs
- Rss20ItemFormatter.cs
- DynamicPropertyReader.cs
- X509SecurityToken.cs