Xojo.IO.TextOutputStream.Create

From Xojo Documentation

Shared Method

Creates a text file for so that text can be written. If the file exists, it will be erased and recreated.

Exceptions

  • IOException for these conditions:
    • containing folder is not writeable
    • the FolderItem is Nil
    • the FolderItem exists and could not be deleted
    • a system I/O error occurs

Sample Code

Create a text file and write data to it:

Using Xojo.Core
Using Xojo.IO

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

Var output As TextOutputStream
Try
output = TextOutputStream.Create(f, TextEncoding.UTF8)
output.WriteLine("Hello, World!")
output.Close
Catch e As IOException
Label1.Value = "Unable to create or write to file."
End Try