Esempio n. 1
0
        private protected override bool RunFileDialog(NativeMethods.OPENFILENAME_I ofn)
        {
            bool result = UnsafeNativeMethods.GetSaveFileName(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));
                }
            }

            return(result);
        }
Esempio n. 2
0
        /// <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);
        }