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
- PenThread.cs
- LOSFormatter.cs
- SqlServer2KCompatibilityAnnotation.cs
- SettingsBindableAttribute.cs
- SessionEndedEventArgs.cs
- TreeViewItem.cs
- CursorConverter.cs
- MutexSecurity.cs
- CatalogPart.cs
- AmbientEnvironment.cs
- GridViewHeaderRowPresenterAutomationPeer.cs
- RoleManagerModule.cs
- RootBuilder.cs
- ObjectTypeMapping.cs
- PermissionAttributes.cs
- EventProvider.cs
- WindowsEditBoxRange.cs
- RijndaelManaged.cs
- OracleConnectionStringBuilder.cs
- StylusPlugin.cs
- ExpandableObjectConverter.cs
- DocumentApplication.cs
- InvalidOperationException.cs
- ToolStripPanelSelectionGlyph.cs
- EntityAdapter.cs
- StackSpiller.Temps.cs
- SizeFConverter.cs
- Ray3DHitTestResult.cs
- Type.cs
- ToolboxService.cs
- SerialPort.cs
- MdiWindowListItemConverter.cs
- __FastResourceComparer.cs
- BuildProviderAppliesToAttribute.cs
- DataGridLinkButton.cs
- XmlSignatureProperties.cs
- TableAutomationPeer.cs
- CutCopyPasteHelper.cs
- EventsTab.cs
- Util.cs
- GeneralTransform3DTo2DTo3D.cs
- EntitySetDataBindingList.cs
- datacache.cs
- assemblycache.cs
- PerformanceCounterManager.cs
- OdbcConnectionFactory.cs
- SvcMapFileLoader.cs
- ConnectionsZone.cs
- ZipIOExtraFieldPaddingElement.cs
- EtwProvider.cs
- Transform3DCollection.cs
- CurrentChangingEventArgs.cs
- ArgumentException.cs
- SoapFormatExtensions.cs
- XmlAttribute.cs
- RootProfilePropertySettingsCollection.cs
- MSAAEventDispatcher.cs
- ComponentCommands.cs
- EmptyEnumerator.cs
- FileDataSourceCache.cs
- StorageComplexTypeMapping.cs
- XmlSchemaSimpleContent.cs
- ValidatorCompatibilityHelper.cs
- RepeaterItemCollection.cs
- versioninfo.cs
- BinaryUtilClasses.cs
- PrimitiveXmlSerializers.cs
- CompiledELinqQueryState.cs
- XmlHierarchicalEnumerable.cs
- Transform3DGroup.cs
- EntityObject.cs
- Size.cs
- ScriptingAuthenticationServiceSection.cs
- SignatureGenerator.cs
- RequiredFieldValidator.cs
- KeyedHashAlgorithm.cs
- CompatibleIComparer.cs
- XmlHierarchyData.cs
- XmlHierarchyData.cs
- StorageSetMapping.cs
- ToolStripSeparatorRenderEventArgs.cs
- NameScopePropertyAttribute.cs
- BuildManagerHost.cs
- GeometryValueSerializer.cs
- State.cs
- CodeArgumentReferenceExpression.cs
- SecurityContext.cs
- PeerToPeerException.cs
- _NegoStream.cs
- SqlConnectionFactory.cs
- Animatable.cs
- PropertySourceInfo.cs
- DataGridViewAdvancedBorderStyle.cs
- XmlCountingReader.cs
- WindowsFormsHostPropertyMap.cs
- SessionChannels.cs
- HtmlControlPersistable.cs
- DataGrid.cs
- TemplateLookupAction.cs
- Walker.cs