I would like to write to text fields to a binary file. I use the below code example from Xojo. It writes the file, but it does not linebreak textfield 1 and 2. What does the code miss?
Thanks!
Ole
Dim f As FolderItem
Dim bs As BinaryStream
//get a folderitem
f = GetFolderItem(“Whole File”)
//create a binary file with the type of text (defined in the file types dialog)
bs = BinaryStream.Create(f, True)
//check to see if it was created
If bs <> Nil Then
bs.Write(TextField1.Text)
bs.Write(TextField2.Text)
//close the binaryStream
bs.Close
End If
Using the read example in Xojo, if I wanted to read the created file (with the 2 lines) and instead of having the output in the “OutputArea.Text”, place line 1 into textfield1 and line 2 into textfield 2… how could I do that?
Ole
Dim f As FolderItem
Dim bs As BinaryStream
//get a folderitem
f = GetFolderItem(“Whole File”)
//make sure it exists before we try to read it
If f.Exists Then
//open the folderitem as a binary file without write privelages
// To open with write privelages, use true instead of false
bs = BinaryStream.Open(f, False)
//make sure we have a binary stream to read from
If bs <> Nil Then
//read the whole binaryStream
[b]OutputArea.Text = bs.Read(bs.Length)[/b]
//close the binaryStream
bs.Close
End If