Write-binary-data-to-file-using-SFTP-protocol - WeOnlyDo Software example code



All

wodCrypt (12)
wodSSH (10)
wodSFTP (23)
wodSSHServer (1)
wodSSHTunnel (11)
wodSSHpackage
wodSFTPdll

wodSSH.NET (10)
wodSFTP.NET (24)
wodFtpDLX.NET (22)
wodWebServer.NET (10)

wodAppUpdate (13)
wodHttpDLX (8)
wodFtpDLX (22)
wodTelnetDLX
wodFTPServer (3)
wodWebServer (10)
wodVPN
wodXMPP (13)
All ** [Visual Basic] ** [C#] ** [VB.NET] **

Write binary data to file using SFTP protocol
VB code
Dim wodSFTP1 As wodSFTPCom
Set wodSFTP1 = New wodSFTPCom

'Authenticate with server using hostname, login, password.
wodSFTP1.HostName = "your_hostname"
wodSFTP1.Login = "your_login"
wodSFTP1.Password = "your_password"
wodSFTP1.Blocking = True  'Use synchronous connections
wodSFTP1.Connect

'Insert some data inside byte.
Dim bData() As Byte
ReDim bData(6)
bData(0) = Asc("t")
bData(1) = Asc("e")
bData(2) = Asc("s")
bData(3) = Asc("t")
bData(4) = Asc("i")
bData(5) = Asc("n")
bData(6) = Asc("g")

'Open remote file for writing.
wodSFTP1.RemoteOpen "/home/somefolder/somefile.txt", PermWrite
'Write binary data at beginning of remote file using RemoteWrite.
wodSFTP1.RemoteWrite bData, 0, 0
'Close remote file when we are done.
wodSFTP1.RemoteClose
VB.NET code
Dim wodSFTP1 As New WeOnlyDo.Client.SFTP

'Authenticate with server using hostname, login, password.
wodSFTP1.Hostname = "your_hostname"
wodSFTP1.Login = "your_login"
wodSFTP1.Password = "your_password"
wodSFTP1.Blocking = True  'Use synchronous connections
wodSFTP1.Connect()

'Insert some data inside byte.
Dim bData() As Byte
ReDim bData(6)
bData(0) = Asc("t")
bData(1) = Asc("e")
bData(2) = Asc("s")
bData(3) = Asc("t")
bData(4) = Asc("i")
bData(5) = Asc("n")
bData(6) = Asc("g")

'Open remote file for writing.
wodSFTP1.RemoteOpen("/home/somepath/somefile.txt", WeOnlyDo.Client.SFTP.RemotePermissions.Write)
'Write binary data at beginning of remote file using RemoteWrite.
wodSFTP1.RemoteWrite(bData, 0)
'Close remote file when we are done.
wodSFTP1.RemoteClose()
C# code
WeOnlyDo.Client.SFTP wodSFTP1 = new WeOnlyDo.Client.SFTP();

//Authenticate with server using hostname, login, password.
wodSFTP1.Hostname = "your_hostname";
wodSFTP1.Login = "your_login";
wodSFTP1.Password = "your_password";
wodSFTP1.Blocking = true;  //Use synchronous connections
wodSFTP1.Connect();

//Insert some data inside byte.
byte[] bData;
bData = new byte[7];
bData[0] = (byte)Convert.ToChar("t");
bData[1] = (byte)Convert.ToChar("e");
bData[2] = (byte)Convert.ToChar("s");
bData[3] = (byte)Convert.ToChar("t");
bData[4] = (byte)Convert.ToChar("i");
bData[5] = (byte)Convert.ToChar("n");
bData[6] = (byte)Convert.ToChar("g");

//Open remote file for writing.
wodSFTP1.RemoteOpen("/home/somepath/somefile.txt", WeOnlyDo.Client.SFTP.RemotePermissions.Write);
//Write binary data at beginning of remote file using RemoteWrite.
wodSFTP1.RemoteWrite(bData, 0);
//Close remote file when we are done.
wodSFTP1.RemoteClose();