Have user select StreamWriter filepath and name
<p>I have a GUI where the user is capable of logging data that comes in from the serial port. I have it set up where I can specify the filename and path that the streamwriter uses in the code, but I would like to have the user select their own path and filename. I was thinking maybe something with the SaveFileDialogue, but I couldn't figure anything out. The file is simply being written as a .csv as well. Open to any suggestions!</p>

<p>My code for declaring the streamwriter is: </p>

<pre><code>    Public Class ReadMeasuredValues
Dim sw as StreamWriter

    Private Sub startread_Click(sender As System.Object, e As System.EventArgs) Handles StartRead.Click
            sw = New StreamWriter(savefiledialog1.filename, False)

    If CheckBox1.Checked = True Then
        sw.WriteLine("Date, Time, Ch 1, Ch 2, Ch 3, Ch 4, Ch 5, Ch 6, Ch 7, Ch 8, Ch 9, Ch 10, Ch 11, Ch 12, Ch 13, Ch 14, Ch 15, Ch 16, Ch 17, Ch 18, Ch 19, Ch 20, Ch 21, Ch 22, Ch 23, Ch 24, Ch 25, Ch 26, Ch 27, Ch 28, Ch 29, Ch 30, Ch 31, Ch 32")
    End If
    End Sub
</code></pre>

<p>Code for launching the SaveFileDialog is </p>

<pre><code>    Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
    saveFileDialog1.Filter = "CSV|*.csv"
    saveFileDialog1.RestoreDirectory = True
    If CheckBox1.Checked = True Then
    savefiledialog1.showDialog()
                End If
    End Sub
</code></pre>