Xojo.IO.TextInputStream.Open

From Xojo Documentation

Shared Method

Creates a TextInputStream and connects it to the specified file.

Exceptions

  • IOException when file = Nil, file does not exist or file is not readable.

Sample Code

Open a file and read all its text:

Using Xojo.Core
Using Xojo.IO

Dim f As FolderItem
f = SpecialFolder.Documents.Child("SaveData.txt")

If Not f.Exists Then
// Cannot read the file if it does not exist
Return
End If

Dim errorText As Text
Try
Dim input As TextInputStream
input = TextInputStream.Open(f, TextEncoding.UTF8)
TextFileArea.Text = input.ReadAll
input.Close
Catch e As IOException
errorText = "File IO Error: " + e.Reason
End Try