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
- FlagPanel.cs
- ObjectAnimationBase.cs
- URLIdentityPermission.cs
- AvTrace.cs
- ClientBuildManager.cs
- PolicyLevel.cs
- UserPersonalizationStateInfo.cs
- oledbmetadatacollectionnames.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- Point3DCollectionConverter.cs
- FreezableOperations.cs
- ParagraphVisual.cs
- ReaderWriterLockWrapper.cs
- EmptyReadOnlyDictionaryInternal.cs
- MarshalDirectiveException.cs
- TreeChangeInfo.cs
- WebDescriptionAttribute.cs
- XpsSerializerWriter.cs
- SqlParameterizer.cs
- DataRow.cs
- SingleQueryOperator.cs
- UniformGrid.cs
- ItemContainerGenerator.cs
- DrawingState.cs
- ByteStreamMessageEncoder.cs
- MsmqIntegrationChannelListener.cs
- ScriptReferenceBase.cs
- DataTableNameHandler.cs
- IsolatedStorageFileStream.cs
- XmlCustomFormatter.cs
- OpCodes.cs
- EventLogger.cs
- FormsAuthenticationModule.cs
- WindowsClientCredential.cs
- TreeNodeConverter.cs
- ValueTypeFixupInfo.cs
- JulianCalendar.cs
- LogLogRecordEnumerator.cs
- StylusButton.cs
- OrderedHashRepartitionStream.cs
- ElementProxy.cs
- HostedNamedPipeTransportManager.cs
- CodeExporter.cs
- XmlSchemaSet.cs
- AssemblyHash.cs
- EventProviderWriter.cs
- TextEditorTyping.cs
- SelectionEditingBehavior.cs
- ConnectionsZoneAutoFormat.cs
- EdmConstants.cs
- MenuBase.cs
- ThrowHelper.cs
- ProfilePropertySettings.cs
- WebPartZone.cs
- ActivityDesignerHighlighter.cs
- RegexCode.cs
- BevelBitmapEffect.cs
- XpsColorContext.cs
- NavigationProgressEventArgs.cs
- ConfigXmlCDataSection.cs
- Tokenizer.cs
- OnOperation.cs
- TransformerInfoCollection.cs
- TemplateControlCodeDomTreeGenerator.cs
- Function.cs
- WebCategoryAttribute.cs
- KeyedPriorityQueue.cs
- MouseButtonEventArgs.cs
- MasterPageParser.cs
- FormViewInsertedEventArgs.cs
- QueryReaderSettings.cs
- Timer.cs
- ContextStaticAttribute.cs
- ColorInterpolationModeValidation.cs
- DockingAttribute.cs
- VBIdentifierDesigner.xaml.cs
- ValueType.cs
- ArrayWithOffset.cs
- ListViewTableRow.cs
- NamedObject.cs
- RequestTimeoutManager.cs
- EditorOptionAttribute.cs
- InkCanvasInnerCanvas.cs
- ItemList.cs
- SafeViewOfFileHandle.cs
- _UriSyntax.cs
- Model3DGroup.cs
- Socket.cs
- PersonalizationDictionary.cs
- ExtensionFile.cs
- SQLInt16Storage.cs
- ApplicationManager.cs
- BaseUriHelper.cs
- CapacityStreamGeometryContext.cs
- ComPlusThreadInitializer.cs
- ProxySimple.cs
- FontSource.cs
- InkCanvasAutomationPeer.cs
- ViewBase.cs
- DataGridColumn.cs