'Get file path stored to string var with SaveFileDialog C# WPF

I am creating an installer and i would like to know how to use SaveFileDialog to get the file path where the user wants to install their mod to. The user should be able to click a button to open up the dialog, navigate to the folder and click select folder and once done is clicked have it stored as {DownloadPath}.



Solution 1:[1]

Try looking at the documentation

There is also a tutorial on this.

Solution 2:[2]

    var filePath = string.Empty;

    var saveFileDialog = new SaveFileDialog
    {
        Filter = @"Exe Files (.exe)|*.exe|All Files (*.*)|*.*"
    };

    saveFileDialog.ShowDialog();
    if (saveFileDialog.FileName != string.Empty)
    {
        filePath = saveFileDialog.FileName;
    }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 JeroenJ
Solution 2 Ohad Cohen