### Read Textfile to List

This example reads the content of a textfile, line-by-line to a list.
' Read the content of a textfile to a list
' Parameter: d = Folder, f = Textfile
' Returns: List. If error then List is empty
`Sub readTextFileToList(d As String, f As String) As List
Dim tr As TextReader
Dim l As List
l.Initialize
Try
' init the textreader and read content into the list
tr.Initialize(File.OpenInput(d, f))
l.AddAll(tr.ReadList)
tr.Close
Catch
Log("Read Text File: Error " & LastException.Message)
If tr.IsInitialized Then tr.Close
End Try
Return l
End Sub`
`Sub buttonTest_Action
Dim l As List = readTextFileToList(File.DirApp, "test.lst")
For i = 0 To l.Size - 1
Log(l.Get(i))
Next
End Sub`

Changed: , Category: TextReader and TextWriter, File: T6C263M1953.htm, ID: 1953