首页 > 解决方案 > 如何在 SaveFileDialog 中设置初始文件名?

问题描述

我为保存文件对话框创建了一个脚本来保存文件。它的初始位置设置为桌面。现在我的问题是,如何在对话框中为文件设置初始“名称”?

这是我的代码:

private SaveFileDialog save = new SaveFileDialog();

    private void Information(string Basic, string nameoffile, string program)
    {

        if (doingsomething) return;

        System.Windows.Forms.MessageBox.Show($"Please select where you would like to store the file)"

        save.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
        if (save.ShowDialog() == DialogResult.OK)

如果对此有答案,请指出我可以找到它的地方。因为我不知道确切的关键字。

标签: c#

解决方案


您可以分配默认名称,例如 save.FileName="File1";


推荐阅读