I'm not sure what do you exactly mean with "packaging a file". But once you have a filestream, you can:
- either copy the stream to a file on local disc or on network folder using the system CopyTo method,
- or copy the stream to an FTP server using the Rebex FTP/SSL component.
Here is an example for both ways:
static void Main(string args)
bool copyUsingFtp = true;
// create a source stream
// (we obtain it simply by opening a file, it woud be more complicated in your application)
using (FileStream src = File.OpenRead(@"c:\temp\file1.txt"))
// copy the stream content to the destination...
// ... etiher using FTP ...
// ... or using system file copy
private static void CopyFile(FileStream src, string dstFilename)
// create stream for destination file (in "overwrite" mode)
using (FileStream dst = new FileStream(dstFilename, FileMode.Create))
// copy the stream using system CopyTo method (new in .NET 4.0)
private static void FtpFile(FileStream src, string dstFilename)
// create a Rebex FTP/SSL client object
using (Ftp client = new Ftp())
// connect and login to the remote FTP server
// upload the source stream to the FTP server
// disconnect from the FTP server
Note: The CopyTo method is new in .NET 4.0. For older versions of .NET framework you can copy streams manually e.g according the following article.