-1

How Can I get File Directory with name from SaveFileDialog?

I tried this:

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

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,483
  • 6
  • 47
  • 84