Set InitialDirectory for SaveFileDialog : SaveFileDialog « GUI Windows Form « C# / C Sharp






Set InitialDirectory for SaveFileDialog

 


using System;
using System.Windows.Forms;

class MainClass {
    static void Main(string[] args) {
        SaveFileDialog dlg = new SaveFileDialog();
        dlg.InitialDirectory = Application.StartupPath;

        if (dlg.ShowDialog() == DialogResult.OK) {
            Console.WriteLine(dlg.FileName);
        }
    }
}

 








Related examples in the same category

1.Call ShowDialog method to show the dialog
2.Use Filter in SaveFileDialog to filter file extension
3.Set CheckFileExists to true