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
- ExtensionQuery.cs
- StreamMarshaler.cs
- FixedSOMTextRun.cs
- SafeViewOfFileHandle.cs
- EventLogPermissionEntryCollection.cs
- Canonicalizers.cs
- WizardStepCollectionEditor.cs
- LinqExpressionNormalizer.cs
- EntityClientCacheEntry.cs
- TextureBrush.cs
- SessionEndedEventArgs.cs
- SystemInformation.cs
- TerminateDesigner.cs
- PermissionRequestEvidence.cs
- IsolatedStorageFilePermission.cs
- Transaction.cs
- dataSvcMapFileLoader.cs
- RegistrationServices.cs
- FontUnitConverter.cs
- Unit.cs
- InternalTypeHelper.cs
- FileIOPermission.cs
- Line.cs
- SmiMetaData.cs
- WebEventTraceProvider.cs
- CodeNamespaceCollection.cs
- DomNameTable.cs
- AsyncOperation.cs
- ValidatingReaderNodeData.cs
- XmlTypeMapping.cs
- ConfigurationSectionGroupCollection.cs
- EventsTab.cs
- Environment.cs
- CodeThrowExceptionStatement.cs
- XmlSchemaChoice.cs
- OptimalBreakSession.cs
- DataGridRow.cs
- Config.cs
- FormView.cs
- SimpleType.cs
- Scanner.cs
- ColorInterpolationModeValidation.cs
- MenuBase.cs
- VSWCFServiceContractGenerator.cs
- CryptoKeySecurity.cs
- CatalogZone.cs
- ReadOnlyDataSource.cs
- VirtualPathProvider.cs
- sqlmetadatafactory.cs
- CatalogPart.cs
- PointConverter.cs
- OdbcCommandBuilder.cs
- HostedTcpTransportManager.cs
- ServiceNameElement.cs
- SrgsToken.cs
- IListConverters.cs
- CodeAttributeDeclarationCollection.cs
- ScriptingJsonSerializationSection.cs
- ClusterRegistryConfigurationProvider.cs
- FtpRequestCacheValidator.cs
- Container.cs
- TcpConnectionPoolSettings.cs
- StateBag.cs
- SchemeSettingElementCollection.cs
- XmlEnumAttribute.cs
- ServiceParser.cs
- RepeaterCommandEventArgs.cs
- MouseWheelEventArgs.cs
- WinFormsUtils.cs
- WorkflowInstanceTerminatedRecord.cs
- PerspectiveCamera.cs
- BufferedOutputStream.cs
- ServiceDescriptionSerializer.cs
- Page.cs
- UnsafeNativeMethods.cs
- GeneralTransform3DCollection.cs
- mediaeventargs.cs
- SqlParameterCollection.cs
- EncryptedPackage.cs
- MailMessage.cs
- ExpressionEditor.cs
- GroupBoxDesigner.cs
- AccessedThroughPropertyAttribute.cs
- PrimitiveXmlSerializers.cs
- XmlDocumentFragment.cs
- StickyNote.cs
- PTConverter.cs
- BufferedGraphics.cs
- SequentialUshortCollection.cs
- CategoryGridEntry.cs
- MultiViewDesigner.cs
- GB18030Encoding.cs
- WebPartUserCapability.cs
- XhtmlStyleClass.cs
- TextSpan.cs
- RandomDelaySendsAsyncResult.cs
- MouseGesture.cs
- __Error.cs
- WindowsToolbarItemAsMenuItem.cs
- TransportSecurityHelpers.cs