I want to avoid opening the Save As dialog in one specific folder. If I open a file from that folder then do a Save As…, it starts in that same folder (as expected). I thought I could just examine InitialDirectory
after calling new SaveFileDialog()
and change it if necessary, but it is an empty string.
Directory.GetCurrentDirectory()
returns the folder containing the executable.
var dialog = new SaveFileDialog();
Console.WriteLine(Directory.GetCurrentDirectory()); // Prints "Z:\Documents\Projects\ProjectName\bin\x64\Debug"
Console.WriteLine(dialog.InitialDirectory); // Prints empty string
How do I ask Windows (7 or 10) which folder the Save As… dialog will start in?
Edit
This is a completely different question than "How do I set the initial directory?". I want to know what the initial directory is going to be before the dialog opens so that I can change it only in the case where it is going to be one specific directory.