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

streamwriter to write to csv file problem, remove last comma from line

$
0
0
Hi
This is the part of the code I use to write from a datatable to a text file seperated by commas. The data is written to the text file delimited by commas OK but it writes a comma on the end of each line which I do not want. How can i remove this?

Thanks




Code:


  sw = New StreamWriter(filePath, False)


        ' write data

        For Each row As DataRow In dt.Rows
            Dim array As Object() = row.ItemArray


            For i = 0 To array.Length - 1


             
                sw.Write(array(i).ToString() & ",")
            Next


            sw.WriteLine()
        Next


        sw.Close()


Viewing all articles
Browse latest Browse all 27044

Trending Articles



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