IOException

From Xojo Documentation
Jump to: navigation, search

Class (inherits from RuntimeException)

Raised when an IO error occurs using BinaryStream, TextOutputStream, or TextInputStream.


Notes

The IOException represents errors that can occur while using the shared methods for opening and creating streams: BinaryStream.Open, BinaryStream.Create, TextOutputStream.Create, TextOutputStream.Append, and TextInputStream.Open. If you are using older APIs, you need to check the FolderItem.LastErrorCode property.


Error Codes

The ErrorNumber property of an IOException may be set to an OS error code.

macOS

The Apple doc page for NSError lists all error codes.

Windows

Windows error codes are available at MSDN.

Linux

Linux error codes are defined in a header file, errno.h.

Example

The following example catches an IOException if it occurs.

Dim f as FolderItem = GetSaveFolderItem(FileTypes1.Text,"Create Example.txt")
If f <> Nil then
Dim t as TextOutputStream = TextOutputStream.Create(f) //this line could raise an IOException.
t.WriteLine(TextField1.text)
End if

Exception err as IOException
MsgBox "an IO exception occurred"

See Also

BinaryStream, RuntimeException, TextInputStream, TextOutputStream classes.

Personal tools
Namespaces

Variants
Actions
Main
Content
Starting Out
Dig Deeper
More Help
Toolbox
About