Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27159

VS 2010 Streamwriter not saving

$
0
0
Hi Guys,

What i'm trying to do here is save to file the items in a listview which meets the users criteria.

Code:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        SaveFileDialog1.Title = "Select save location file..."
        SaveFileDialog1.InitialDirectory = "C:"
        SaveFileDialog1.Filter = "Text Files|*.txt"
        SaveFileDialog1.FileName = "files.txt"
        SaveFileDialog1.ShowDialog()

        For Each itm As String In formMain.ListBoxMain.Items

            Dim arraySplit As String() = itm.Split(">"c)
            Dim fir As String = arraySplit(1)
            Dim sec As String = arraySplit(1)

            If (fir >= comboBoxcf.Text) And (sec >= comboBoxtf.Text) Then

                Using SW As New StreamWriter("files.txt", True)

                    SW.WriteLine(itm)

                End Using

            End If

        Next

    End Sub

The problem is the streamwriter isn't saving any file, we get the saveDialog() popup but after hitting save nothing is saved, am i doing something wrong?

cheers for any help guys

Graham

Viewing all articles
Browse latest Browse all 27159

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>