/// <include file='doc\OpenFileDialog.uex' path='docs/doc[@for="OpenFileDialog.RunFileDialog"]/*' /> /// <devdoc> /// Displays a file open dialog. /// </devdoc> /// <internalonly/> internal override bool RunFileDialog(NativeMethods.OPENFILENAME_I ofn) { //We have already done the demand in EnsureFileDialogPermission but it doesn't hurt to do it again Debug.WriteLineIf(IntSecurity.SecurityDemand.TraceVerbose, "FileDialogOpenFile Demanded in OpenFileDialog.RunFileDialog"); IntSecurity.FileDialogOpenFile.Demand(); bool result = UnsafeNativeMethods.GetOpenFileName(ofn); if (!result) { // Something may have gone wrong - check for error condition // int errorCode = SafeNativeMethods.CommDlgExtendedError(); switch (errorCode) { case NativeMethods.FNERR_INVALIDFILENAME: throw new InvalidOperationException(SR.GetString(SR.FileDialogInvalidFileName, FileName)); case NativeMethods.FNERR_SUBCLASSFAILURE: throw new InvalidOperationException(SR.GetString(SR.FileDialogSubLassFailure)); case NativeMethods.FNERR_BUFFERTOOSMALL: throw new InvalidOperationException(SR.GetString(SR.FileDialogBufferTooSmall)); } } return(result); }
/// <summary> /// Displays a file open dialog. /// </summary> private protected override bool RunFileDialog(NativeMethods.OPENFILENAME_I ofn) { bool result = UnsafeNativeMethods.GetOpenFileName(ofn); if (!result) { // Something may have gone wrong - check for error condition switch (Comdlg32.CommDlgExtendedError()) { case Comdlg32.FNERR.INVALIDFILENAME: throw new InvalidOperationException(string.Format(SR.FileDialogInvalidFileName, FileName)); case Comdlg32.FNERR.SUBCLASSFAILURE: throw new InvalidOperationException(SR.FileDialogSubLassFailure); case Comdlg32.FNERR.BUFFERTOOSMALL: throw new InvalidOperationException(SR.FileDialogBufferTooSmall); } } return(result); }
/// <include file='doc\OpenFileDialog.uex' path='docs/doc[@for="OpenFileDialog.RunFileDialog"]/*' /> /// <devdoc> /// Displays a file open dialog. /// </devdoc> /// <internalonly/> internal override bool RunFileDialog(NativeMethods.OPENFILENAME_I ofn) { bool result = UnsafeNativeMethods.GetOpenFileName(ofn); if (!result) { // Something may have gone wrong - check for error condition // int errorCode = SafeNativeMethods.CommDlgExtendedError(); switch (errorCode) { case NativeMethods.FNERR_INVALIDFILENAME: throw new InvalidOperationException(SR.GetString(SR.FileDialogInvalidFileName, FileName)); case NativeMethods.FNERR_SUBCLASSFAILURE: throw new InvalidOperationException(SR.GetString(SR.FileDialogSubLassFailure)); case NativeMethods.FNERR_BUFFERTOOSMALL: throw new InvalidOperationException(SR.GetString(SR.FileDialogBufferTooSmall)); } } return(result); }