Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I prevent a SaveFileDialog from prompting twice to replace/overwrite a file?

How can I stop a System.Windows.Forms.SaveFileDialog from prompting twice to replace a selected file, and instead prompt only once?

Either I'm missing something, there's something wrong with my install, or the default behaviour is just dumb.

var saveFileDialog = new SaveFileDialog();
saveFileDialog.ShowDialog();
// User selects file and clicks "Save" within the dialog

I'm not doing anything special at all, this is in an empty Windows Forms project, targeting .NET Framework 4.7.2.

Edit: Added full Program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var saveFileDialog = new SaveFileDialog();
            saveFileDialog.ShowDialog();
        }
    }
}
like image 910
Macklin Avatar asked Dec 03 '18 14:12

Macklin


1 Answers

This seems to be a bug in the latest .Net version. It does not happen on Windows builds prior to 10.0.17763

like image 138
Peter S. Avatar answered Oct 13 '22 13:10

Peter S.