System::IO::FileStream class

FileStream class

Represents a file stream supporting synchronous and asynchronous read and write operations. Objects of this class should only be allocated using System::MakeObject() function. Never create instance of this type on stack or using operator new, as it will result in runtime errors and/or assertion faults. Always wrap this class into System::SmartPtr pointer and use this pointer to pass it to functions as argument.

class FileStream : public System::IO::Stream

Methods

MethodDescription
Close() overrideCloses the current FileStream object.
FileStream(const String&, FileMode)Constructs a new instance of FileStream class and initializes it with the specified parameters.
FileStream(const String&, FileMode, FileAccess, FileShare, int32_t, FileOptions)Constructs a new instance of FileStream class and initializes it with the specified parameters.
FileStream(const FileStream&)
Flush() overrideClears this stream’s buffers and writes all buffered data to the underlying file.
Flush(bool)Clears this stream’s buffers and writes all buffered data to the underlying file. Synonym for method Flush().
get_CanRead() const overrideDetermines if the stream is readable.
get_CanSeek() const overrideDetermines if the stream supports seeking.
get_CanWrite() const overrideDetermines if the stream is writable.
get_Length() const overrideReturns the length of the stream in bytes.
get_Name() constReturns the name of the file encapsulated by the current FileStream object.
get_Position() const overrideReturns the current position of the stream.
operator=(const FileStream&)
Read(const ArrayPtr<uint8_t>&, int32_t, int32_t) overrideReads the specified number of bytes from the stream and writes them to the specified byte array.
Read(const System::Details::ArrayView<uint8_t>&, int32_t, int32_t) overrideReads the specified number of bytes from the stream and writes them to the specified byte array.
ReadByte() overrideReads a single byte from the stream and returns a 32-bit integer value equivalent to the value of the read byte.
Seek(int64_t, SeekOrigin) overrideSets the position of the stream represented by the current object.
set_Position(int64_t) overrideFlushes the stream and then sets the stream’s position.
SetLength(int64_t) overrideSets the length of the stream represented by the current object.
Write(const ArrayPtr<uint8_t>&, int32_t, int32_t) overrideWrites the specified subrange of bytes from the specified byte array to the stream.
Write(const System::Details::ArrayView<uint8_t>&, int32_t, int32_t) overrideWrites the specified subrange of bytes from the specified byte array to the stream.
WriteByte(uint8_t) overrideWrites the specified unsigned 8-bit integer value to the stream.
~FileStream()Destructor.

Fields

FieldDescription
static constexpr DefaultBufferSizeDefault value of the number of bytes bufferred during read and write operations.
static NullA stream with no underlying storage.

See Also