IoError
Error enum · namespace System · Since 0.05
error IoErrorThe errors of file and folder operations (File, Directory, FileStream).
A function returns IoError<T>: the result, or one of these codes. A switch can handle each code:
switch (File.ReadAllText(path)){ case string text: Console.WriteLine(text); break; case IoError.CannotOpen: Console.WriteLine("no such file"); break; case error e: Console.WriteLine(e.Message); break;}A typed result converts to a plain Error<T> (the code becomes an int).
Values
Section titled “Values”| Value | Number | Description |
|---|---|---|
CannotOpen |
1 |
The file does not exist or cannot be read. |
CannotWrite |
2 |
Writing or closing failed (the disk is full, …). |
CannotDelete |
3 |
The file or folder cannot be deleted. |
AlreadyExists |
4 |
The target exists already (e.g. File.Copy without overwriting). |
InvalidText |
5 |
The content is not valid in the requested encoding (File.ReadAllText with an Encoding). |
CannotCreate |
6 |
The file cannot be created or truncated (a missing folder, no permission). |
CannotMove |
7 |
Moving or renaming failed (File.Move, Directory.Move), e.g. to another drive on AmigaOS or without permission. |