Dart.Ftp Namespace > Ftp Class > Put Method : Put(String,Int64,StoreType) Method |
Public Overloads Function Put( _ ByVal remotePath As String, _ ByVal remoteOffset As Long, _ ByVal storeType As StoreType _ ) As Stream
Dim instance As Ftp Dim remotePath As String Dim remoteOffset As Long Dim storeType As StoreType Dim value As Stream value = instance.Put(remotePath, remoteOffset, storeType)
public Stream Put( string remotePath, long remoteOffset, StoreType storeType )
public: Stream^ Put( String^ remotePath, int64 remoteOffset, StoreType storeType )
The returned stream must be closed before sending more commands over the control connection (the server response to the store command is read when the stream is closed).
DataIsBusy returns true until the stream this method opens is closed.
Characters specified in the remote path are sent to the server unmodified. If the path contains characters that are invalid for the server host filesystem, it may cause the operation to fail with an FtpProtocolException.
private void processRecords() { //Open the local file for transfer, with 'using' so it is automatically closed and disposed using (FileStream localFileStream = File.OpenRead(myRecordsFile)) { //Request a stream for writing to the remote file, with 'using' so it is automatically closed and disposed using (Stream remoteStream = ftp1.Put(myRecordsFile, 0, StoreType.Replace)) { //Create the buffer to read data into for transfer. //In this example, each record is 64 bytes, but not delimited byte[] buffer = new byte[64]; //Create the end of record tag as a byte array. byte[] endOfRecord = System.Text.Encoding.Default.GetBytes("[END OF RECORD]" + Environment.NewLine); int count = -1; //Write until all local file records are written. do { //Read the data into the buffer. count = localFileStream.Read(buffer, 0, buffer.Length); //Write the record to the remote file. remoteStream.Write(buffer, 0, buffer.Length); //Write the end of record tag. remoteStream.Write(endOfRecord, 0, endOfRecord.Length); } while (count > 0); } } }
Private Sub processRecords() 'Open the local file for transfer, with 'using' so it is automatically closed and disposed Using localFileStream As FileStream = File.OpenRead(myRecordsFile) 'Request a stream for writing to the remote file, with 'using' so it is automatically closed and disposed Using remoteStream As Stream = ftp1.Put(myRecordsFile, 0, StoreType.Replace) 'Create the buffer to read data into for transfer. 'In this example, each record is 64 bytes, but not delimited Dim buffer(63) As Byte 'Create the end of record tag as a byte array. Dim endOfRecord() As Byte = System.Text.Encoding.Default.GetBytes("[END OF RECORD]" & Environment.NewLine) Dim count As Integer = -1 'Write until all local file records are written. Do 'Read the data into the buffer. count = localFileStream.Read(buffer, 0, buffer.Length) 'Write the record to the remote file. remoteStream.Write(buffer, 0, buffer.Length) 'Write the end of record tag. remoteStream.Write(endOfRecord, 0, endOfRecord.Length) Loop While count > 0 End Using End Using End Sub