TextOutputStream.Open

From Xojo Documentation

Revision as of 13:50, 9 October 2019 by PLefebvre (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Shared Method

TextOutputStream.Open(f as FolderItem) As TextOutputStream

New in 2019r2

Supported for all project types and targets.

Opens the passed file so that text can be added to the end of the file.

Notes

If no file exists at the specified location, one is created. If the file cannot be created or opened for adding, an IOException is raised. Add text by calling Write or WriteLine.

Example

This example adds the text in TextField1 to the text file that was opened by GetOpenFolderItem:

Var f As FolderItem = FolderItem.ShowOpenFileDialog(FileTypes1.Text)
If f <> Nil Then
Try
Var t As TextOutputStream = TextOutputStream.Open(f)
t.Write(TextField1.Value)
Catch e As IOException
// handle error
End Try
End If