I use SaveFileDialog
to select the path where I want to save a file. I set InitialDirectory
to some folder, but I want to limit the save locations to that folder or subfolders of that folder. Is this possible?
SaveFileDialog dialog = new SaveFileDialog();
dialog.InitialDirectory = "SomePath"//this is the path that I want to be root folder
No it is not possible.
You can't directly set this as a Property on the SaveFileDialog
. But you can try to do it by using the FileOk
event to validate if the file is in that directory and otherwise cancel the event!
dialog.FileOk +=
delegate (object sender, CancelEventArgs e)
{
if (dialog.FileName is in wrong directory)
{
e.Cancel = true;
}
};
As mentioned, the next best option is to build your own Dialog!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With