Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42220

VS 2008 StreamWriter Overwritting issue! Please help I'm so mad.

$
0
0
Code:

  Private Sub Item()

        Dim strWriter As New StreamWriter(FILE_NAME, False)
        strWriter.Write("<Items>" & vbCrLf)

        Dim arrFirst() As String = Itemsbox.Text.Split(vbNewLine)
        For Each i In arrFirst
            strWriter.Write("<" & i & ">" & vbCrLf)

        Next
        strWriter.Write("</Items>")
        strWriter.Close()
        Dim strReader As New StreamReader(FILE_NAME)
        My.Settings.XML = strReader.ReadToEnd
        strReader.Close()

            MsgBox("Text Appended to the File")
    End Sub

I need my file to look like this

<Items> (first line)
<Info Info Info Info>
<New info new info>
<Newer Info Newer info>(so it continues to updates the list without going over </Items>)
</Items>


But this code I spent all day working at. Now I can insert multiple lines of code to the thing at once but each time I update it (press the button for Item() again) it resets and puts my <Items> and </Items> in ****ed up places or overight it completely and doesn't correctly work. Can somebody help me out here? I hope you can understand me.

Viewing all articles
Browse latest Browse all 42220

Trending Articles



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