I have a string which contains many rows of data which has been converted from a datatable. The last row of my string has nothing within it, no spaces or anything. How can I get rid of this row? I have tried regex, but cant seem to get anything that does the job. I am writing in VB.
Code as it stands:
Dim objSW As StreamWriter
Dim merRersult As String
Dim objSW As StreamWriter
Dim objFS As New FileStream(path, FileMode.CreateNew)
objFS.Close()
objSW = New StreamWriter(path, True)
merRersult = Delta.Utilities.Convert.DataTableToCSV(dt, True, sep)
'Write out mer file
Dim merResultNoLines As String
merResultNoLines = Regex.Replace(merRersult, "^\r?\n?$", "")
objSW.WriteLine(merRersult)
objSW.Close()
Thanks in advance
You should try to use String.TrimEnd method in the following way: