Dart.Ftp Namespace > Ftp Class > Get Method : Get(String,Int64) Method |
Public Overloads Function Get( _ ByVal remotePath As String, _ ByVal remoteOffset As Long _ ) As Stream
Dim instance As Ftp Dim remotePath As String Dim remoteOffset As Long Dim value As Stream value = instance.Get(remotePath, remoteOffset)
public Stream Get( string remotePath, long remoteOffset )
public: Stream^ Get( String^ remotePath, int64 remoteOffset )
The returned stream must be closed before sending more commands over the control connection (the server response to the RETR command is read when the stream is closed).
DataIsBusy returns true until the stream this method opens is closed.
A file retrieval may be aborted by using Connection.Write("ABOR\r\n"), reading the stream until the server closes it, and using Connection.ReadToDelimiter("\r\n") to get the response from the ABOR command sent.
private void streamRecords() { //Establish the stream with 'using' so it is automatically closed and disposed using (Stream dataStream = ftp1.Get("myRecords.txt", 0)) { //Set up a buffer to hold the incoming data. byte[] buffer = new byte[1024]; int count = -1; //Loop as long as we can read data from the incoming stream. do { //Read data from the stream into the buffer. count = dataStream.Read(buffer, 0, buffer.Length); //Write any data read into the textbox. textBox1.AppendText(System.Text.Encoding.Default.GetString(buffer, 0, count)); } while (count > 0); } }
Private Sub streamRecords() 'Establish the stream with 'using' so it is automatically closed and disposed Using dataStream As Stream = ftp1.Get("myRecords.txt", 0) 'Set up a buffer to hold the incoming data. Dim buffer(1023) As Byte Dim count As Integer = -1 'Loop as long as we can read data from the incoming stream. Do 'Read data from the stream into the buffer. count = dataStream.Read(buffer, 0, buffer.Length) 'Write any data read into the textbox. textBox1.AppendText(System.Text.Encoding.Default.GetString(buffer, 0, count)) Loop While count > 0 End Using End Sub