title: Save stream of savefiledialog in c#
body: <p>In my wpf app I have an "Export" button that suppose to save some json file to chosen path. </p>
  
  <p>I mean my question is how to write the file, let's say he has the path <code>D:\somefile.json</code> to the chosen location that the user chose from save dualog?</p>
  
  <p>Here my code:</p>
  
  <pre><code>void Export_button_Click(object sender, RoutedEventArgs e)
  {
          Stream myStream;
          SaveFileDialog saveFileDialog1 = new SaveFileDialog();
          saveFileDialog1.Filter = "Json files (*.json)|*.json";
          saveFileDialog1.FilterIndex = 2;
          saveFileDialog1.RestoreDirectory = true;
  
          if (saveFileDialog1.ShowDialog() == DialogResult.OK)
          {
              if ((myStream = saveFileDialog1.OpenFile()) != null)
              {
                  // Code to write the stream goes here.
                  myStream.Close();
              }
  }
  </code></pre>
  
  <p>This should be something like:</p>
  
  <p><code>Copy(StreamOf(D:\somefile.json),ChosenPath)</code></p>