NET SFTP Library
SCPPutBinary(Stream,String,DateTime,DateTime,String,IFireProgress) Method
Example 






KellermanSoftware.NetSFtpLibrary Namespace > SFTP Class > SCPPutBinary Method : SCPPutBinary(Stream,String,DateTime,DateTime,String,IFireProgress) Method
Local file stream
Remote file name
The modification date to set
The acess date to set
A permissions number string
Monitor the progress
Upload a file using the SCP Protocol
Syntax
'Declaration
 
Public Overloads Sub SCPPutBinary( _
   ByVal localStream As System.IO.Stream, _
   ByVal remoteFileName As System.String, _
   ByVal modifiedDate As System.Date, _
   ByVal accessDate As System.Date, _
   ByVal permissions As System.String, _
   ByVal fireProgress As IFireProgress _
) 
'Usage
 
Dim instance As SFTP
Dim localStream As System.IO.Stream
Dim remoteFileName As System.String
Dim modifiedDate As System.Date
Dim accessDate As System.Date
Dim permissions As System.String
Dim fireProgress As IFireProgress
 
instance.SCPPutBinary(localStream, remoteFileName, modifiedDate, accessDate, permissions, fireProgress)
public void SCPPutBinary( 
   System.IO.Stream localStream,
   System.string remoteFileName,
   System.DateTime modifiedDate,
   System.DateTime accessDate,
   System.string permissions,
   IFireProgress fireProgress
)
public procedure SCPPutBinary( 
    localStream: System.IO.Stream;
    remoteFileName: System.String;
    modifiedDate: System.DateTime;
    accessDate: System.DateTime;
    permissions: System.String;
    fireProgress: IFireProgress
); 
public function SCPPutBinary( 
   localStream : System.IO.Stream,
   remoteFileName : System.String,
   modifiedDate : System.DateTime,
   accessDate : System.DateTime,
   permissions : System.String,
   fireProgress : IFireProgress
);
public: void SCPPutBinary( 
   System.IO.Stream* localStream,
   System.string* remoteFileName,
   System.DateTime modifiedDate,
   System.DateTime accessDate,
   System.string* permissions,
   IFireProgress* fireProgress
) 
public:
void SCPPutBinary( 
   System.IO.Stream^ localStream,
   System.String^ remoteFileName,
   System.DateTime modifiedDate,
   System.DateTime accessDate,
   System.String^ permissions,
   IFireProgress^ fireProgress
) 

Parameters

localStream
Local file stream
remoteFileName
Remote file name
modifiedDate
The modification date to set
accessDate
The acess date to set
permissions
A permissions number string
fireProgress
Monitor the progress
Remarks
https://blogs.oracle.com/janp/entry/how_the_scp_protocol_works
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  = "anonymus"; // replace with your user name
sftp.Password = "user@mail.com"; // replace with your password
 
sftp.Connect();
 
byte[] buffer = new byte[] { 0x01, 0x02, 0x03 };
MemoryStream stream = new MemoryStream(buffer);
string newFileName = Guid.NewGuid().ToString() + ".dat";
 
DateTime accessDate = new DateTime(2011, 10, 09, 08, 07, 06, 0, DateTimeKind.Utc);
DateTime modifiedDate = new DateTime(2012, 11, 10, 09, 08, 07, 0, DateTimeKind.Utc);
sftp.SCPPutBinary(stream, "TestFolder/" + newFileName, modifiedDate, accessDate, "3765", null);
Dim sftp As New SFTP() 'Trial Mode
'Dim 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 = "anonymus" ' replace with your user name
sftp.Password = "user@mail.com" ' replace with your password
 
sftp.Connect()
 
Dim buffer() As Byte = { &H1, &H2, &H3 }
Dim stream As New MemoryStream(buffer)
Dim newFileName As String = Guid.NewGuid().ToString() & ".dat"
 
Dim accessDate As New Date(2011, 10, 09, 08, 07, 06, 0, DateTimeKind.Utc)
Dim modifiedDate As New Date(2012, 11, 10, 09, 08, 07, 0, DateTimeKind.Utc)
sftp.SCPPutBinary(stream, "TestFolder/" & newFileName, modifiedDate, accessDate, "3765", Nothing)
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