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
BaseFtpClientThe 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
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
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
Position
Gets or sets the position of the stream
public override long Position { get; set; }
Property Value
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
~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
intWhere to start in the buffer
count
intNumber 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
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
intWhere to start in the buffer
count
intNumber of bytes to read
token
CancellationTokenThe cancellation token for this task
Returns
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
CancellationTokenThe cancellation token for this task
Returns
SetLength(long)
Sets the length of this stream
public override void SetLength(long value)
Parameters
value
longValue 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
longThe 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
intWhere to start in the buffer
count
intThe 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
intWhere to start in the buffer
count
intThe number of bytes to write to the buffer
token
CancellationTokenThe CancellationToken for this task
Returns
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
CancellationTokenThe CancellationToken for this task