TextInputStream.Open

From Xojo Documentation

Revision as of 00:03, 13 February 2022 by Gperlman (talk | contribs) (Example)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!
Shared Method

TextInputStream.Open(f As FolderItem) As TextInputStream

New in 2009r4

Supported for all project types and targets.

Opens the passed FolderItem to be read as a text file. Returns a TextInputStream. An IO error will trigger an IOException.

Notes

Reading from the file will begin at the start of the file. If you wish to read from any other point in the file, use the BytePosition property to move the read position.

This shared method replaces the deprecated FolderItem.OpenAsTextFile.

Example

Var f As FolderItem
Var t As TextInputStream
f = FolderItem.ShowOpenFileDialog("text") // file type defined in File Type Sets Editor
If f <> Nil Then
t = TextInputStream.Open(f)
t.Encoding = Encodings.UTF8 //specify encoding of input stream
TextArea1.Text = t.ReadAll
t.Close
End if