Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / WinForms / Managed / System / WinForms / FileDialogCustomPlacesCollection.cs / 1 / 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
- ShaderEffect.cs
- Base64Encoding.cs
- ScriptingWebServicesSectionGroup.cs
- EncryptedPackageFilter.cs
- DataServiceException.cs
- X509UI.cs
- DataGridParentRows.cs
- NetNamedPipeSecurityMode.cs
- ByteAnimationBase.cs
- GestureRecognizer.cs
- BindingContext.cs
- TextLineBreak.cs
- CryptoStream.cs
- ExternalFile.cs
- PlainXmlSerializer.cs
- SafeNativeMethodsCLR.cs
- OutputCacheProviderCollection.cs
- recordstate.cs
- OracleParameterCollection.cs
- IsolatedStorageFilePermission.cs
- DynamicPropertyHolder.cs
- GlyphElement.cs
- GradientStop.cs
- SiteMapPath.cs
- AesCryptoServiceProvider.cs
- HyperLinkColumn.cs
- XmlHierarchicalDataSourceView.cs
- WindowVisualStateTracker.cs
- SqlDataSourceQueryEditorForm.cs
- RNGCryptoServiceProvider.cs
- NavigationPropertyEmitter.cs
- SynchronizedDispatch.cs
- SimpleHandlerBuildProvider.cs
- PrintDialogDesigner.cs
- SchemaImporterExtensionElement.cs
- FileDataSourceCache.cs
- ResourceProperty.cs
- AtomParser.cs
- SourceSwitch.cs
- ListenerElementsCollection.cs
- IPipelineRuntime.cs
- DetailsViewUpdateEventArgs.cs
- cache.cs
- ItemType.cs
- GacUtil.cs
- XpsViewerException.cs
- SystemGatewayIPAddressInformation.cs
- SqlTransaction.cs
- Propagator.JoinPropagator.JoinPredicateVisitor.cs
- Query.cs
- ClipboardProcessor.cs
- NamespaceCollection.cs
- TypePropertyEditor.cs
- Convert.cs
- BackStopAuthenticationModule.cs
- Sql8ConformanceChecker.cs
- GenericTextProperties.cs
- EditCommandColumn.cs
- SignalGate.cs
- Vector3DAnimation.cs
- XmlIlTypeHelper.cs
- DesignSurfaceEvent.cs
- XmlSequenceWriter.cs
- ClientData.cs
- LayoutEvent.cs
- SafeNativeMethods.cs
- SpellerError.cs
- SelectedDatesCollection.cs
- WebHttpDispatchOperationSelectorData.cs
- ExpanderAutomationPeer.cs
- MetafileHeaderWmf.cs
- UniqueID.cs
- WinFormsComponentEditor.cs
- TraceSwitch.cs
- TypeAccessException.cs
- StreamWriter.cs
- RsaSecurityToken.cs
- RouteItem.cs
- PropertyPathConverter.cs
- SoapInteropTypes.cs
- XmlDataSourceNodeDescriptor.cs
- HelpEvent.cs
- ThicknessAnimationUsingKeyFrames.cs
- XPathDocument.cs
- BridgeDataReader.cs
- InputProviderSite.cs
- EntityCommand.cs
- ExpandCollapsePatternIdentifiers.cs
- messageonlyhwndwrapper.cs
- EventListener.cs
- _TimerThread.cs
- DependencyObjectType.cs
- EntityContainer.cs
- DefaultTextStore.cs
- Activator.cs
- DocumentViewerBaseAutomationPeer.cs
- ToolStripRenderer.cs
- StylusDownEventArgs.cs
- ConfigurationValidatorAttribute.cs
- DesignerCommandSet.cs