Search code examples
c#savefiledialog

Export text to a browsed file in wpf


I'm trying to export some text to a file browsed by the user and create it if this file does not exists. What I've done till now is to use OpenFileDialog but I don't know if it's the right way to do it and also if it is I don't know how to continue


Solution

  • You can use the SaveFileDialog()

        var dialog = new SaveFileDialog();
        dialog.ShowDialog();
        var path = dialog.FileName;
        File.WriteAllText(path, "YourData");