SFTPStream.Read Method (String)

Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

[Visual Basic]
Overloads Public Function Read( _
ByVal buffer As Byte(), _
ByVal offset As Int32, _
ByVal count As Int32 _
) As Int32
[C#]
public Int32 Read(
   byte[] buffer,    Int32 offset,
Int32 count
);

Parameters

buffer

An array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source.

offset

The zero-based byte offset in buffer at which to begin storing the data read from the current stream.

count

The maximum number of bytes to be read from the current stream.

Return Value

The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if the end of the stream has been reached.

Remarks

Use the CanRead property to determine whether the current instance supports reading. Method will read a maximum of count bytes from the current stream and store them in buffer beginning at offset. The current position within the stream is advanced by the number of bytes read; however, if an exception occurs, the current position within the stream remains unchanged.

Method will return the number of bytes read. The return value is zero only if the position is currently at the end of the stream. Fewer bytes than requested can be returned even if the end of the stream has not been reached.

Method will block until at least one byte of data can be read, in the event that no data is available. Read returns 0 only when there is no more data in the stream and no more is expected (such as a closed socket or end of file).
 

See Also

SFTPStream Class | SFTPStream Members | WeOnlyDo.Client Namespace