It is necessary to do so that the file is saved without displaying the save dialog box with the same name and extension in the same folder. Now it works like this.

try { TextRange conversionText = ConversionText; using (MemoryStream stream = new MemoryStream()) { conversionText.Save(stream, System.Windows.DataFormats.Rtf); stream.Seek(0, SeekOrigin.Begin); using (StreamReader reader = new StreamReader(stream)) { IRtfDocument rtfDocument = RtfInterpreterTool.BuildDoc(reader); RtfHtmlConverter htmlConverter = new RtfHtmlConverter(rtfDocument); textBox.Text = htmlConverter.Convert(); } System.Windows.Forms.SaveFileDialog save = new System.Windows.Forms.SaveFileDialog(); if (save.ShowDialog() == System.Windows.Forms.DialogResult.OK) { using (StreamWriter sw = new StreamWriter(save.FileName)) { sw.Write(textBox.Text); } } } } catch (Exception exception) { System.Windows.MessageBox.Show(this, "Error " + exception.Message, Title, MessageBoxButton.OK, MessageBoxImage.Error); } 
  • one
    What is the question? Use your filename anywhere in the user's home directory, similar to / home / user. - LXA Nov.
  • Even I did not understand something like that so is FileName = @ "Z: /Files/Core/Help/help.html"? - Pavel

2 answers 2

 System.Windows.Forms.SaveFileDialog save = new System.Windows.Forms.SaveFileDialog(); if (save.ShowDialog() == System.Windows.Forms.DialogResult.OK) using (StreamWriter sw = new StreamWriter(save.FileName)) 

You create a dialog box and then open it save.ShowDialog() , and this dialog box will be active until you close it. Then, creating a stream, you use the result of the selection in the file selection dialog box.

You need to remove the dialog box and use the FileName variable with the path you need.

    All figured it was necessary to just do so

     using (StreamWriter sw = new StreamWriter(@"Z:\Files\Core\Help\Help.html")) { sw.Write(textBox.Text); }