Class BinaryStorage
Provides easy serialization to binary files (optionally wrapped in ZIP archives).
public static class BinaryStorage
- Inheritance
-
objectBinaryStorage
Methods
LoadBinary<T>(Stream)
Loads an object from a binary file.
public static T LoadBinary<T>(Stream stream)
Parameters
stream
StreamThe binary file to be loaded.
Returns
- T
The loaded object.
Type Parameters
T
The type of object the binary stream shall be converted into.
Exceptions
- InvalidDataException
A problem occurred while deserializing the binary data.
LoadBinary<T>(string)
Loads an object from a binary file.
public static T LoadBinary<T>(string path)
Parameters
path
stringThe binary file to be loaded.
Returns
- T
The loaded object.
Type Parameters
T
The type of object the binary stream shall be converted into.
Remarks
Uses see cref="AtomicRead"/> internally.
Exceptions
- IOException
A problem occurred while reading the file.
- UnauthorizedAccessException
Read access to the file is not permitted.
- InvalidDataException
A problem occurred while deserializing the binary data.
SaveBinary<T>(T, Stream)
Saves an object in a binary stream.
public static void SaveBinary<T>(this T data, Stream stream) where T : notnull
Parameters
data
TThe object to be stored.
stream
StreamThe binary file to be written.
Type Parameters
T
The type of object to be saved in a binary stream.
SaveBinary<T>(T, string)
Saves an object in a binary file.
public static void SaveBinary<T>(this T data, string path) where T : notnull
Parameters
data
TThe object to be stored.
path
stringThe binary file to be written.
Type Parameters
T
The type of object to be saved in a binary stream.
Remarks
This method performs an atomic write operation when possible.
Exceptions
- IOException
A problem occurred while writing the file.
- UnauthorizedAccessException
Write access to the file is not permitted.