Upload a stream of data to the FTP server in the current working directory.
Namespace: EnterpriseDT.Net.FtpAssembly: edtFTPnetPRO (in edtFTPnetPRO.dll) Version: 9.4.0.40
Syntax
C# |
---|
public virtual void UploadStream( Stream srcStream, string remoteFile ) |
Visual Basic |
---|
Public Overridable Sub UploadStream ( _ srcStream As Stream, _ remoteFile As String _ ) |
Visual C++ |
---|
public: virtual void UploadStream( Stream^ srcStream, String^ remoteFile ) |
Parameters
- srcStream
- Type: System.IO..::..Stream
Input stream of data to put.
- remoteFile
- Type: System..::..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.
Examples
The following example uploads the contents of
a MemoryStream to the server and downloads the
same file into another MemoryStream:
Copy | |
---|---|
// 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(); |