Skip to main content

FileStream Class

Namespace: System.IO · Assembly: GHIElectronics.TinyCLR.IO

A read/write stream backed by a file on a mounted file system. Construct via File.OpenRead(string) / File.OpenWrite(string) / File.Create(string).

public class FileStream : Stream

Constructors

FileStream(string path, FileMode mode)

public FileStream(string path, FileMode mode) : this(path, mode, (mode == FileMode.Append ? FileAccess.Write : FileAccess.ReadWrite), FileShare.Read, FileStream.BufferSizeDefault)

No description available.

ParameterTypeDescription
pathstring
modeFileMode

FileStream(string path, FileMode mode, FileAccess access)

public FileStream(string path, FileMode mode, FileAccess access) : this(path, mode, access, FileShare.Read, FileStream.BufferSizeDefault)

No description available.

ParameterTypeDescription
pathstring
modeFileMode
accessFileAccess

FileStream(string path, FileMode mode, FileAccess access, FileShare share)

public FileStream(string path, FileMode mode, FileAccess access, FileShare share) : this(path, mode, access, share, FileStream.BufferSizeDefault)

No description available.

ParameterTypeDescription
pathstring
modeFileMode
accessFileAccess
shareFileShare

FileStream(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize)

public FileStream(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize)

No description available.

ParameterTypeDescription
pathstring
modeFileMode
accessFileAccess
shareFileShare
bufferSizeint

Properties

CanRead

public override bool CanRead { get; }

Gets a value indicating whether the current stream supports reading. (inherited)

CanWrite

public override bool CanWrite { get; }

Gets a value indicating whether the current stream supports writing. (inherited)

CanSeek

public override bool CanSeek { get; }

Gets a value indicating whether the current stream supports seeking. (inherited)

IsAsync

public virtual bool IsAsync { get; }

No description available.

Length

public override long Length { get; }

Gets length of bytes in the stream. (inherited)

Name

public string Name { get; }

The native API name. (inherited)

Position

public override long Position { get; set; }

Gets or sets the current possition in the stream. (inherited)

Methods

Dispose(bool disposing)

protected override void Dispose(bool disposing)

Closes a response stream, if present. (inherited)

ParameterTypeDescription
disposingboolNot used.

Flush()

public override void Flush()

Writes unwritten data to the file. (inherited)

SetLength(long value)

public override void SetLength(long value)

Adjusts the length of the array. This can be used to trim the end of the array. (inherited)

ParameterTypeDescription
valuelong

Read(byte[] buffer, int offset, int count)

public override int Read(byte[] buffer, int offset, int count)

Reads a block of bytes from the stream. (inherited)

ParameterTypeDescription
bufferbyte[]
offsetintThe byte offset in the array at which read bytes will be placed.
countintThe maximun number of bytes to read.

Returns int

Seek(long offset, SeekOrigin origin)

public override long Seek(long offset, SeekOrigin origin)

Sets the current position of this stream to a given value. (inherited)

ParameterTypeDescription
offsetlongThe offset of the positon relative to the origin.
originSeekOriginSpecified the beginning, end or current postion as a reference point to apply the offset.

Returns long — The new postion in the stream.

Write(byte[] buffer, int offset, int count)

public override void Write(byte[] buffer, int offset, int count)

Writes a block of bytes to the file stream. (inherited)

ParameterTypeDescription
bufferbyte[]
offsetintThe byte offset in the array from which to start writing bytes to the stream.
countintThe number of bytes to write.