Back to product page

RemoteWrite method


Writes to remote file.

Type

Void

Syntax

  • C#
  • VB.NET
public Void RemoteWrite(Byte[] Data, Int64 RemotePos);
The RemoteWrite(Data,RemotePos) syntax has these parts:
DataHolds data to be written in remote file.
RemotePosPosition in the remote file where write occurs.

public Void RemoteWrite(String Data, Int64 RemotePos);
The RemoteWrite(Data,RemotePos) syntax has these parts:
DataHolds data to be written in remote file.
RemotePosPosition in the remote file where write occurs.

public Void RemoteWrite(Byte[] Data, Int32 Offset, Int32 Count, Int64 RemotePos);
The RemoteWrite(Data,Offset,Count,RemotePos) syntax has these parts:
DataHolds data to be written in remote file.
OffsetOffset of data in Data buffer.
CountTotal number of bytes to write from the Data buffer.
RemotePosPosition in the remote file where write occurs.

public Sub RemoteWrite(ByVal Data As Byte[], ByVal RemotePos As Int64)
The RemoteWrite(Data,RemotePos) syntax has these parts:
DataHolds data to be written in remote file.
RemotePosPosition in the remote file where write occurs.

public Sub RemoteWrite(ByVal Data As String, ByVal RemotePos As Int64)
The RemoteWrite(Data,RemotePos) syntax has these parts:
DataHolds data to be written in remote file.
RemotePosPosition in the remote file where write occurs.

public Sub RemoteWrite(ByVal Data As Byte[], ByVal Offset As Int32, ByVal Count As Int32, ByVal RemotePos As Int64)
The RemoteWrite(Data,Offset,Count,RemotePos) syntax has these parts:
DataHolds data to be written in remote file.
OffsetOffset of data in Data buffer.
CountTotal number of bytes to write from the Data buffer.
RemotePosPosition in the remote file where write occurs.

Remarks

The RemoteWrite method write Data to specific position in remote file, opened with RemoteOpen method. When data is fully written, Done event will be fired where you can write more data, close the file etc.. During the transfer, Progress event WILL NOT be fired.

You can, for example, write data like this:
 
WeOnlyDo.Client.SFTP sftp1 = new WeOnlyDo.Client.SFTP();
sftp1.Hostname = "x.y.z";
sftp1.Login = "xyz";
sftp1.Password = "abc";
sftp1.Blocking = true;
sftp1.Connect();
sftp1.RemoteOpen("/tmp/newfile",
        WeOnlyDo.Client.SFTP.RemotePermissions.Read |
        WeOnlyDo.Client.SFTP.RemotePermissions.Write |
        WeOnlyDo.Client.SFTP.RemotePermissions.Truncate |
        WeOnlyDo.Client.SFTP.RemotePermissions.Create);
sftp1.RemoteWrite("this is a test", 0);
sftp1.RemoteWrite("another test", 10);
 
byte[] b = sftp1.RemoteRead(0, -1);
MessageBox.Show(new String(System.Text.Encoding.ASCII.GetChars(b)));
sftp1.RemoteClose();
 

After you finish writing all the data, don't forget to call RemoteClose. You can not call other methods until RemoteClose is called (for example, you cannot call PutFile).

Platforms

Windows