edtFTPnet/PRO - Secure FTP component for .NET | Free Trial | Pricing

ExFTPConnectionUploadStream(Stream, String) Method

Upload a stream of data to the FTP server in the current working directory.

Definition

Namespace: EnterpriseDT.Net.Ftp
Assembly: edtFTPnetPRO (in edtFTPnetPRO.dll) Version: 12.7.0.0
C#
public override void UploadStream(
	Stream srcStream,
	string remoteFile
)

Parameters

srcStream  Stream
Input stream of data to put.
remoteFile  String
Name of remote file in current working directory.

Remarks

The stream is closed after the transfer is complete if CloseStreamsAfterTransfer is true (the default) and are left open otherwise. If the stream is left open the its position will be at the end of the stream. Use Seek(Int64, SeekOrigin) to change the position if required.

Example

The following example uploads the contents of a MemoryStream to the server and downloads the same file into another MemoryStream:
// build StringStream (defined below) for "Hello world" byte[] bytes = Encoding.ASCII.GetBytes("Hello world"); MemoryStream inStr = new MemoryStream(bytes); // upload the stream to a file on the server ftpConnection.UploadStream(inStr, "helloworld.txt"); inStr.Close(); // create a MemoryStream and download into it MemoryStream outStr = new MemoryStream(); ftpConnection.DownloadStream(outStr, "helloworld.txt"); outStr.Seek(0, SeekOrigin.Begin); string str = Encoding.GetString(outStr.GetBuffer()); Console.WriteLine(str); outStr.Close();

See Also