I/O Subsystem

Stream, File, Directory, BinaryReader, Compression, Hashing, and IsolatedStorage.

System::IO::Stream

include/System/IO/Stream.hpp | src/System/IO/Stream.cpp

Abstract base class for all streams. Status: Partial

MethodDescription
Read(buffer, offset, count)Pure virtual. Read bytes into buffer.
Close()Close the stream.
LengthStream length in bytes (property).
PositionCurrent position (property).
Seek(offset, origin)Set position relative to origin.

Concrete Stream Types

ClassHeaderDescription
FileStreamSystem/IO/FileStream.hppFile-backed stream. Read, Write, Seek.
MemoryStreamSystem/IO/MemoryStream.hppIn-memory byte buffer stream.
BufferedStreamSystem/IO/BufferedStream.hppBuffered wrapper around another stream.
IO::Compression::GZipStreamSystem/IO/Compression/GZipStream.hppgzip compression/decompression (ZLIB, PIMPL, 64KB buffers).
IO::Compression::DeflateStreamSystem/IO/Compression/DeflateStream.hppRaw DEFLATE stream (-MAX_WBITS), XNB-compatible.
IsolatedStorage::IsolatedStorageFileStreamSystem/IO/IsolatedStorage/IsolatedStorageFileStream.hppFile stream within isolated storage.

Text Readers and Writers

ClassHeaderDescription
TextReaderSystem/IO/TextReader.hppAbstract text reader
TextWriterSystem/IO/TextWriter.hppAbstract text writer
StreamReaderSystem/IO/StreamReader.hppReads text from a stream
StreamWriterSystem/IO/StreamWriter.hppWrites text to a stream
StringReaderSystem/IO/StringReader.hppReads from a string
StringWriterSystem/IO/StringWriter.hppWrites to a string

Binary I/O

ClassHeaderDescription
BinaryReaderSystem/IO/BinaryReader.hppReads primitive types from a stream in binary format
BinaryWriterSystem/IO/BinaryWriter.hppWrites primitive types to a stream in binary format

File and Directory

ClassHeaderKey Methods
FileSystem/IO/File.hppReadAllBytes, WriteAllBytes, ReadAllText, WriteAllText, Exists, Delete, Copy, Move
DirectorySystem/IO/Directory.hppExists, Create, Delete, GetFiles, GetDirectories, GetCurrentDirectory
PathSystem/IO/Path.hppCombine, GetFileName, GetExtension, GetDirectoryName, GetFullPath
FileInfoSystem/IO/FileInfo.hppFile metadata and operations
DirectoryInfoSystem/IO/DirectoryInfo.hppDirectory metadata and operations
DriveInfoSystem/IO/DriveInfo.hppDrive information

Compression

include/System/IO/Compression/

ClassStatusDescription
GZipStreamDonegzip; backed by ZLIB; PIMPL; 64KB buffers
DeflateStreamDoneRaw DEFLATE; -MAX_WBITS; XNB-compatible
ZipArchiveDoneZIP read+create; backed by miniz; PIMPL
CompressionModeDoneCompress / Decompress enum

Hashing

include/System/IO/Hashing/

ClassStatusDescription
XxHash32DonexxHash 32-bit non-cryptographic hash
XxHash64DonexxHash 64-bit non-cryptographic hash
Crc32DoneCRC-32 non-cryptographic hash
NonCryptographicHashAlgorithmDoneBase class

RandomAccess

include/System/IO/RandomAccess.hpp | src/System/IO/RandomAccess.cpp

Status: Done — but POSIX-only on Linux/macOS.

Uses pread/pwrite/fsync on POSIX, and Win32 OVERLAPPED ReadFile/WriteFile on Windows. Emscripten throws PlatformNotSupportedException.

IsolatedStorage

include/System/IO/IsolatedStorage/

Provides sandboxed file storage. The storage root is determined by SharpRuntime::Storage::StoragePaths::GetIsolatedStorageRoot().

ClassStatus
IsolatedStorageFilePartial
IsolatedStorageFileStreamPartial
IsolatedStorageExceptionDone

Platform Notes

⚠ POSIX-only subsystems
  • System::IO::RandomAccess — uses pread/pwrite; POSIX-only (has Win32 fallback)
  • Network streams — see Platform Layer