-1

How Can I get File Directory with name from SaveFileDialog?

I tried this:

string directory = File.GetFileDirectory with name ;
Dave Zych
  • 21,581
  • 7
  • 51
  • 66

1 Answers1

4

Use System.IO.Path.GetDirectoryName to get the directory from the dialog's FileName property.

SaveFileDialog saveDialog = new SaveFileDialog();
saveDialog.ShowDialog();
string directory = Path.GetDirectoryName(saveDialog.FileName);
Cyral
  • 13,999
  • 6
  • 50
  • 90