NET SFTP Library
DownloadStreamAsync(Stream,String,Int64,Object) Method
Example 






KellermanSoftware.NetSFtpLibrary Namespace > SFTP Class > DownloadStreamAsync Method : DownloadStreamAsync(Stream,String,Int64,Object) Method
The local file stream to write to
The FTP file path
The byte offset to start downloading from
Your custom object to be returned with Started, Progress, and Completed Events
Download to a file stream from the SSH server asynchronously from the specified byte offset.
Syntax
'Declaration
 
Public Overloads Sub DownloadStreamAsync( _
   ByVal localStream As System.IO.Stream, _
   ByVal ftpFileName As System.String, _
   ByVal restart As System.Long, _
   ByVal customObject As System.Object _
) 
'Usage
 
Dim instance As SFTP
Dim localStream As System.IO.Stream
Dim ftpFileName As System.String
Dim restart As System.Long
Dim customObject As System.Object
 
instance.DownloadStreamAsync(localStream, ftpFileName, restart, customObject)
public void DownloadStreamAsync( 
   System.IO.Stream localStream,
   System.string ftpFileName,
   System.long restart,
   System.object customObject
)
public procedure DownloadStreamAsync( 
    localStream: System.IO.Stream;
    ftpFileName: System.String;
    restart: System.Int64;
    customObject: System.TObject
); 
public function DownloadStreamAsync( 
   localStream : System.IO.Stream,
   ftpFileName : System.String,
   restart : System.long,
   customObject : System.Object
);
public: void DownloadStreamAsync( 
   System.IO.Stream* localStream,
   System.string* ftpFileName,
   System.long restart,
   System.Object* customObject
) 
public:
void DownloadStreamAsync( 
   System.IO.Stream^ localStream,
   System.String^ ftpFileName,
   System.int64 restart,
   System.Object^ customObject
) 

Parameters

localStream
The local file stream to write to
ftpFileName
The FTP file path
restart
The byte offset to start downloading from
customObject
Your custom object to be returned with Started, Progress, and Completed Events
Example
SFTP sftp = new SFTP(); //Trial Mode            
//SFTP sftp = new SFTP("place user name here", "place license key here");
 
// set the name of the SSH server( its URL )
sftp.HostAddress = "some.sftp.server.com"; // replace with your SFTP server
sftp.UserName  = "anonymous"; // replace with your user name
sftp.Password = "user@mail.com"; // replace with your password
 
Stream myStream = File.OpenWrite("c:\\uploadfile1.txt");
sftp.DownloadStreamAsync(myStream, "uploadfile1.txt", 2500);
 
while (sftp.IsBusy == true)
{
    System.Threading.Thread.Sleep(100);
}
 
myStream.Close();
Dim sftp As SFTP = New SFTP() 'Trial Mode
'Dim sftp As SFTP = New SFTP("place user name here", "place license key here");
 
' set the name of the SSH server( its URL )
sftp.HostAddress = "some.sftp.server.com" ' replace with your SFTP server
sftp.UserName  = "anonymous" ' replace with your user name
sftp.Password = "user@mail.com" ' replace with your password
 
Dim myStream As Stream = File.OpenWrite("c:\uploadfile1.txt")
sftp.DownloadStreamAsync(myStream, "uploadfile1.txt", 2500)
 
Do While sftp.IsBusy = True
   System.Threading.Thread.Sleep(100)
Loop
 
myStream.Close()
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

SFTP Class
SFTP Members
Overload List