gpt4 book ai didi

c# - 如何防止 SaveFileDialog 提示两次以替换/覆盖文件?

转载 作者:太空狗 更新时间:2023-10-29 22:56:37 25 4
gpt4 key购买 nike

如何阻止 System.Windows.Forms.SaveFileDialog 提示两次以替换选定的文件,而是只提示一次?

要么是我遗漏了什么,要么是我的安装有问题,要么是默认行为很愚蠢。

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

我没有做任何特别的事情,这是在一个空的 Windows 窗体项目中,目标是 .NET Framework 4.7.2。

编辑:添加了完整的 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();
}
}
}

最佳答案

这似乎是最新 .Net 版本中的错误。它不会发生在 10.0.17763 之前的 Windows 版本上

关于c# - 如何防止 SaveFileDialog 提示两次以替换/覆盖文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53595963/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com