简体   繁体   中英

How to set a Initial file name in a SaveFileDialog?

I created a script for a save-file-dialog to save a file. It has the Initial location set to the desktop. Now my question is, how do i set an initial "name" for the file in the dialog?

Here's my code:

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)

If there is an answer for this, please point where I can find it. Because i don't know the exact keyword.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM