Table of Contents

Class FtpDataStream

Namespace
FluentFTP
Assembly
FluentFTP.dll

Base class for data stream connections

public class FtpDataStream : FtpSocketStream, IDisposable, IAsyncDisposable
Inheritance
FtpDataStream
Implements
Inherited Members
Extension Methods

Constructors

FtpDataStream(BaseFtpClient)

Creates a new data stream object

public FtpDataStream(BaseFtpClient conn)

Parameters

conn BaseFtpClient

The control connection to be used for carrying out this operation

Properties

CommandStatus

Gets the status of the command that was used to open this data channel

public FtpReply CommandStatus { get; set; }

Property Value

FtpReply

ControlConnection

Gets or sets the control connection for this data stream. Setting the control connection causes the object to be cloned and a new connection is made to the server to carry out the task. This ensures that multiple streams can be opened simultaneously.

public BaseFtpClient ControlConnection { get; set; }

Property Value

BaseFtpClient

Length

Gets or sets the length of the stream. Only valid for file transfers and only valid on servers that support the Size command.

public override long Length { get; }

Property Value

long

Position

Gets or sets the position of the stream

public override long Position { get; set; }

Property Value

long

Methods

Close()

Closes the connection and reads (and discards) the server's reply

public void Close()

CloseAsync(CancellationToken)

Closes the connection and reads (and discards) the server's reply

public override ValueTask CloseAsync(CancellationToken token = default)

Parameters

token CancellationToken

Returns

ValueTask

~FtpDataStream()

Finalizer

protected ~FtpDataStream()

Read(byte[], int, int)

Reads data off the stream

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

Parameters

buffer byte[]

The buffer to read into

offset int

Where to start in the buffer

count int

Number of bytes to read

Returns

int

The number of bytes read

Read(Span<byte>)

Reads data off the stream

public override int Read(Span<byte> buffer)

Parameters

buffer Span<byte>

The buffer to read into

Returns

int

The number of bytes read

ReadAsync(byte[], int, int, CancellationToken)

Reads data off the stream asynchronously

public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken token)

Parameters

buffer byte[]

The buffer to read into

offset int

Where to start in the buffer

count int

Number of bytes to read

token CancellationToken

The cancellation token for this task

Returns

Task<int>

The number of bytes read

ReadAsync(Memory<byte>, CancellationToken)

Reads data off the stream asynchronously

public override ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken token)

Parameters

buffer Memory<byte>

The buffer to read into

token CancellationToken

The cancellation token for this task

Returns

ValueTask<int>

The number of bytes read

SetLength(long)

Sets the length of this stream

public override void SetLength(long value)

Parameters

value long

Value to apply to the Length property

SetPosition(long)

Sets the position of the stream. Intended to be used internally by FtpControlConnection.

public void SetPosition(long pos)

Parameters

pos long

The position

Write(byte[], int, int)

Writes data to the stream

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

Parameters

buffer byte[]

The buffer to write to the stream

offset int

Where to start in the buffer

count int

The number of bytes to write to the buffer

Write(ReadOnlySpan<byte>)

Writes data to the stream

public override void Write(ReadOnlySpan<byte> buffer)

Parameters

buffer ReadOnlySpan<byte>

The buffer to write to the stream

WriteAsync(byte[], int, int, CancellationToken)

Writes data to the stream asynchronously

public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken token)

Parameters

buffer byte[]

The buffer to write to the stream

offset int

Where to start in the buffer

count int

The number of bytes to write to the buffer

token CancellationToken

The CancellationToken for this task

Returns

Task

WriteAsync(ReadOnlyMemory<byte>, CancellationToken)

Writes data to the stream asynchronously

public override ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationToken token)

Parameters

buffer ReadOnlyMemory<byte>

The buffer to write to the stream

token CancellationToken

The CancellationToken for this task

Returns

ValueTask