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
- DeriveBytes.cs
- ExitEventArgs.cs
- BufferModeSettings.cs
- ProviderConnectionPointCollection.cs
- SchemaCollectionCompiler.cs
- ItemContainerPattern.cs
- objectquery_tresulttype.cs
- ProofTokenCryptoHandle.cs
- ServiceHostingEnvironment.cs
- StreamReader.cs
- CollectionViewGroupRoot.cs
- PropertyChangingEventArgs.cs
- StringResourceManager.cs
- Completion.cs
- PseudoWebRequest.cs
- ContentPosition.cs
- DocumentDesigner.cs
- Rfc2898DeriveBytes.cs
- _BufferOffsetSize.cs
- RadioButton.cs
- ExtractCollection.cs
- DataServiceProviderMethods.cs
- XmlSchemaObjectTable.cs
- NavigationFailedEventArgs.cs
- SmtpFailedRecipientsException.cs
- FileLevelControlBuilderAttribute.cs
- EmbeddedMailObjectsCollection.cs
- SerializationAttributes.cs
- TemplatePartAttribute.cs
- SqlDataSourceRefreshSchemaForm.cs
- ObjectContextServiceProvider.cs
- DBConnectionString.cs
- _ProxyRegBlob.cs
- XsdBuildProvider.cs
- Timer.cs
- DefaultObjectMappingItemCollection.cs
- DescendantOverDescendantQuery.cs
- HitTestDrawingContextWalker.cs
- HttpCapabilitiesSectionHandler.cs
- HttpValueCollection.cs
- HttpStreamMessage.cs
- ConstraintCollection.cs
- TextProperties.cs
- EventWaitHandleSecurity.cs
- AssemblyAttributesGoHere.cs
- OverflowException.cs
- ContourSegment.cs
- ColumnMapTranslator.cs
- MetadataAssemblyHelper.cs
- odbcmetadatacolumnnames.cs
- LongTypeConverter.cs
- HttpClientCertificate.cs
- ComponentResourceManager.cs
- StatusBar.cs
- ExpressionHelper.cs
- SqlInfoMessageEvent.cs
- RowType.cs
- TextModifierScope.cs
- PipelineModuleStepContainer.cs
- MobileFormsAuthentication.cs
- TreeViewAutomationPeer.cs
- TypedReference.cs
- SymLanguageType.cs
- EvidenceTypeDescriptor.cs
- MemoryRecordBuffer.cs
- ToolStripSplitStackLayout.cs
- XmlSchemaFacet.cs
- ApplicationActivator.cs
- OdbcParameterCollection.cs
- DropShadowEffect.cs
- PasswordTextContainer.cs
- RSAPKCS1KeyExchangeDeformatter.cs
- TextServicesManager.cs
- AppDomainManager.cs
- SortQuery.cs
- ByteRangeDownloader.cs
- DataGridToolTip.cs
- LogicalTreeHelper.cs
- ProcessingInstructionAction.cs
- DecimalAnimation.cs
- ComponentChangedEvent.cs
- SmiEventSink.cs
- AgileSafeNativeMemoryHandle.cs
- DynamicPropertyHolder.cs
- XMLSchema.cs
- Image.cs
- ObjectHelper.cs
- NotImplementedException.cs
- MenuItem.cs
- ScrollBarAutomationPeer.cs
- SemanticTag.cs
- FormViewPageEventArgs.cs
- Random.cs
- DataGridItemCollection.cs
- LocalizeDesigner.cs
- JoinCqlBlock.cs
- HttpHandlerActionCollection.cs
- SafeArrayTypeMismatchException.cs
- SolidColorBrush.cs
- MetadataItemEmitter.cs