Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get path without file name from saveFileDialog?

Tags:

c#

winforms

I am try to get my path from SaveFileDialog without my file name in order to create a DirectoryInfo object

private void btnBrowseCapture_Click(object sender, EventArgs e)
{
    SaveFileDialog saveFileDialogBrowse2 = new SaveFileDialog();
    saveFileDialogBrowse2.Filter = "Pcap file|*.pcap";
    saveFileDialogBrowse2.Title = "Save an pcap File";
    saveFileDialogBrowse2.ShowDialog();

    if (saveFileDialogBrowse2.FileName != "")
    {
        string str = saveFileDialogBrowse2.FileName;

    }
}
like image 836
user1710944 Avatar asked Dec 08 '22 20:12

user1710944


1 Answers

You can also use System.IO.Path.GetDirectoryName for this purpose

System.IO.Path.GetDirectoryName(filePath)
like image 177
dotINSolution Avatar answered Dec 11 '22 10:12

dotINSolution