Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / WinForms / Managed / System / WinForms / FileDialogCustomPlacesCollection.cs / 4 / 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) { //Assert FileIOPermission for getting the paths for the favorites new FileIOPermission(PermissionState.Unrestricted).Assert(); //Walk backwards for (int i = this.Items.Count - 1; i >= 0; --i) { FileDialogCustomPlace customPlace = this.Items[i]; 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) { //Assert FileIOPermission for getting the paths for the favorites new FileIOPermission(PermissionState.Unrestricted).Assert(); //Walk backwards for (int i = this.Items.Count - 1; i >= 0; --i) { FileDialogCustomPlace customPlace = this.Items[i]; 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
- SoapInteropTypes.cs
- Vector3DCollectionConverter.cs
- ContextMarshalException.cs
- Normalizer.cs
- DefaultValueTypeConverter.cs
- X509LogoTypeExtension.cs
- FullTextState.cs
- WindowsIdentity.cs
- AppDomainUnloadedException.cs
- DescriptionAttribute.cs
- MetadataItemSerializer.cs
- ArithmeticException.cs
- BooleanToVisibilityConverter.cs
- IndicShape.cs
- TabletCollection.cs
- MessageContractMemberAttribute.cs
- SessionParameter.cs
- DeploymentSection.cs
- SqlDependency.cs
- NameNode.cs
- PerfCounters.cs
- Journaling.cs
- DataStorage.cs
- ExceptionHelpers.cs
- ViewCellSlot.cs
- MimeObjectFactory.cs
- ToolboxComponentsCreatedEventArgs.cs
- ActivityCodeDomSerializationManager.cs
- SoapRpcMethodAttribute.cs
- BoolExpression.cs
- HttpModulesSection.cs
- LinkUtilities.cs
- CompressedStack.cs
- PackageDigitalSignatureManager.cs
- TrackingServices.cs
- TreeView.cs
- HandlerBase.cs
- LogSwitch.cs
- ISFTagAndGuidCache.cs
- DataGridViewDataErrorEventArgs.cs
- Funcletizer.cs
- WorkflowElementDialogWindow.xaml.cs
- SchemaConstraints.cs
- DoubleConverter.cs
- BitStream.cs
- DetailsViewCommandEventArgs.cs
- LiteralText.cs
- ShaderEffect.cs
- HyperLinkField.cs
- FaultFormatter.cs
- PolyLineSegment.cs
- TextSelectionProcessor.cs
- XmlAttributes.cs
- ProfileSettingsCollection.cs
- XmlTextReaderImplHelpers.cs
- UnsafeNativeMethodsTablet.cs
- LZCodec.cs
- AdornerPresentationContext.cs
- TreeNode.cs
- userdatakeys.cs
- EnvironmentPermission.cs
- ServerIdentity.cs
- EntityReference.cs
- Camera.cs
- AlternateView.cs
- Rect3DValueSerializer.cs
- ScriptResourceHandler.cs
- DataColumnMappingCollection.cs
- DeleteIndexBinder.cs
- MultiBinding.cs
- DataSourceSerializationException.cs
- DataGridToolTip.cs
- TextDecorations.cs
- TextDecorations.cs
- PathData.cs
- SafeCancelMibChangeNotify.cs
- PropertyState.cs
- CodeChecksumPragma.cs
- SelectionProviderWrapper.cs
- MouseBinding.cs
- PriorityBindingExpression.cs
- DefaultEvaluationContext.cs
- CommonDialog.cs
- MetadataAssemblyHelper.cs
- UserNamePasswordClientCredential.cs
- QueryableFilterUserControl.cs
- TemplateInstanceAttribute.cs
- FlowLayout.cs
- ListBoxAutomationPeer.cs
- DataConnectionHelper.cs
- RoleBoolean.cs
- XmlValidatingReaderImpl.cs
- BufferModesCollection.cs
- InputBuffer.cs
- ArcSegment.cs
- IdentityModelStringsVersion1.cs
- FileIOPermission.cs
- CodeArrayIndexerExpression.cs
- TagPrefixCollection.cs
- ImageClickEventArgs.cs