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

Var 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

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