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
- Rect3DValueSerializer.cs
- Assert.cs
- MDIClient.cs
- TextServicesCompartmentEventSink.cs
- HttpHandlersSection.cs
- GeneratedContractType.cs
- CustomAttribute.cs
- PassportAuthenticationModule.cs
- smtpconnection.cs
- UrlUtility.cs
- DateTimeConstantAttribute.cs
- SchemaEntity.cs
- PartialCachingAttribute.cs
- DesignerTransactionCloseEvent.cs
- RenderData.cs
- NamedPermissionSet.cs
- TransactionContextValidator.cs
- OpenTypeLayoutCache.cs
- OrderedDictionary.cs
- PageEventArgs.cs
- WebPartConnectionsDisconnectVerb.cs
- HelloMessageApril2005.cs
- MouseEventArgs.cs
- ToolStripItemTextRenderEventArgs.cs
- HtmlInputHidden.cs
- NameValueSectionHandler.cs
- SystemIPInterfaceProperties.cs
- XmlSchemaExternal.cs
- HatchBrush.cs
- DefaultProxySection.cs
- ResolveDuplexAsyncResult.cs
- Color.cs
- Freezable.cs
- SecUtil.cs
- StoreItemCollection.Loader.cs
- AlphabetConverter.cs
- SQLStringStorage.cs
- documentsequencetextpointer.cs
- CharacterBuffer.cs
- StyleBamlTreeBuilder.cs
- LinqDataSourceHelper.cs
- EntityCollection.cs
- KernelTypeValidation.cs
- WrappedReader.cs
- DataViewSettingCollection.cs
- TransformedBitmap.cs
- Variant.cs
- XsltOutput.cs
- LineServicesCallbacks.cs
- PeerEndPoint.cs
- Accessible.cs
- ArcSegment.cs
- ColumnWidthChangedEvent.cs
- sqlser.cs
- DrawingImage.cs
- HttpCapabilitiesBase.cs
- NativeMethods.cs
- RestClientProxyHandler.cs
- ReverseInheritProperty.cs
- Catch.cs
- AccessedThroughPropertyAttribute.cs
- X509ChainPolicy.cs
- PlanCompiler.cs
- DataGridViewComboBoxEditingControl.cs
- RemoteCryptoTokenProvider.cs
- ToolboxDataAttribute.cs
- TraceHandlerErrorFormatter.cs
- ConfigXmlDocument.cs
- XmlEntityReference.cs
- DesignObjectWrapper.cs
- PowerEase.cs
- XmlComplianceUtil.cs
- ProfileProvider.cs
- Evidence.cs
- HtmlEncodedRawTextWriter.cs
- HtmlTextArea.cs
- PersistChildrenAttribute.cs
- XamlReader.cs
- SecureConversationSecurityTokenParameters.cs
- XmlElementAttribute.cs
- CellLabel.cs
- TableLayoutStyleCollection.cs
- WorkflowDispatchContext.cs
- PieceNameHelper.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- IISMapPath.cs
- MetadataArtifactLoaderResource.cs
- FormParameter.cs
- SqlStatistics.cs
- InstanceDescriptor.cs
- Itemizer.cs
- LinqDataSourceDisposeEventArgs.cs
- TypeUtils.cs
- PassportPrincipal.cs
- SectionInput.cs
- UInt64Converter.cs
- MSHTMLHost.cs
- SqlDataRecord.cs
- MorphHelpers.cs
- GlobalDataBindingHandler.cs