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
- GB18030Encoding.cs
- TypedTableHandler.cs
- SelectedGridItemChangedEvent.cs
- SerialStream.cs
- MLangCodePageEncoding.cs
- DependencyPropertyValueSerializer.cs
- PermissionSet.cs
- X509SecurityTokenProvider.cs
- NotImplementedException.cs
- TypeExtension.cs
- HtmlCommandAdapter.cs
- SqlGenerator.cs
- TextEditorMouse.cs
- SetState.cs
- BookmarkTable.cs
- Fonts.cs
- DbConvert.cs
- Baml2006ReaderContext.cs
- CatalogPartCollection.cs
- DataBoundControlHelper.cs
- StateChangeEvent.cs
- StreamAsIStream.cs
- SendMailErrorEventArgs.cs
- RoutedUICommand.cs
- Size.cs
- PublisherIdentityPermission.cs
- QilPatternFactory.cs
- DataTableCollection.cs
- SqlInternalConnectionTds.cs
- Axis.cs
- HttpRequestTraceRecord.cs
- AccessDataSourceView.cs
- StoragePropertyMapping.cs
- DelegateSerializationHolder.cs
- Brush.cs
- CalendarSelectionChangedEventArgs.cs
- ChangeBlockUndoRecord.cs
- ProtectedConfiguration.cs
- CounterSampleCalculator.cs
- ScriptingJsonSerializationSection.cs
- XmlCDATASection.cs
- TreeNodeCollectionEditor.cs
- XmlSerializerVersionAttribute.cs
- TimelineGroup.cs
- AndCondition.cs
- Comparer.cs
- TextTrailingWordEllipsis.cs
- FormViewInsertedEventArgs.cs
- WindowsFormsSynchronizationContext.cs
- DocumentViewerBaseAutomationPeer.cs
- HwndSubclass.cs
- PartialList.cs
- HwndKeyboardInputProvider.cs
- FileReader.cs
- DataGridRow.cs
- ProjectionNode.cs
- Model3DGroup.cs
- NotifyParentPropertyAttribute.cs
- Accessible.cs
- OutgoingWebRequestContext.cs
- SchemaTypeEmitter.cs
- DownloadProgressEventArgs.cs
- QilExpression.cs
- CombinedTcpChannel.cs
- PointAnimationClockResource.cs
- FlowDocumentFormatter.cs
- LineProperties.cs
- FormsAuthentication.cs
- WebPartMenuStyle.cs
- X509ScopedServiceCertificateElement.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- ListControl.cs
- StrokeNode.cs
- Graphics.cs
- CompModHelpers.cs
- BoundField.cs
- XmlReaderSettings.cs
- Unit.cs
- CollectionChangedEventManager.cs
- FtpRequestCacheValidator.cs
- CompiledXpathExpr.cs
- FileInfo.cs
- SqlConnectionPoolGroupProviderInfo.cs
- StylusPointPropertyInfoDefaults.cs
- ResXResourceWriter.cs
- XmlnsPrefixAttribute.cs
- CodeThrowExceptionStatement.cs
- TreeViewCancelEvent.cs
- _ShellExpression.cs
- DataObjectAttribute.cs
- MappingMetadataHelper.cs
- ImageDrawing.cs
- MultipleFilterMatchesException.cs
- UriParserTemplates.cs
- CommandExpr.cs
- ApplicationDirectoryMembershipCondition.cs
- GridItemPattern.cs
- Exception.cs
- MethodExpr.cs
- SingletonConnectionReader.cs