ListBox to Txt File

Hello, I have this code to save a ListBox into a File.txt, but when its saves, automatic add a Line without text. I try with other things but it don’t work and the same line appear. This Is The Code, any Help? Thanks in Advance

Dim f as FolderItem Dim tos as TextOutputStream Dim strOutFileName As String Dim strOutString As String ' Assign the required file name to the output file strOutFileName = "file.txt" ' Open output file f=SpecialFolder.Desktop.Child(strOutFileName) If f <> Nil Then tos = TextOutputStream.Create(f) ' Assign the required value to output string strOutString = Listbox1.Cell(-1,-1).ToText tos.WriteLine strOutString tos.Close End If

you can use BinaryStream

  Dim f as FolderItem
  if f  <> nil then
    dim output as BinaryStream
    output = BinaryStream.Create(f, true)
    output.write Listbox1.Cell(-1,-1)
    MsgBox "Error"
  end if

dim output as BinaryStream strOutString = Listbox1.Cell(-1,-1).ToText tos.WriteLine strOutString

WriteLine writes the text passed to the TextOutputStream and appends the Delimiter to the end of the line.


tos.Write strOutString


Oh Thanks to All it works perfectly