Legacy replacement functions

I have run into some other issues while upgradig some of our legacy code.

I used to do stream based operations rather than direct file IO.

Here is a snipit of the original code

public MemoryStream GetFile(string _fileName)
{
MemoryStream IN_Stream = new MemoryStream();
ftpIN.CloseStreamsAfterTransfer = false;
ftpIN.DownloadStream(IN_Stream, _fileName);
return IN_Stream
}

In the new libary I don't see the replacements for the stream operations. What would be the replacement functions for this?

Thanks in advance

You may want to look at the following function:
HRESULT DownloadFileEx(
[in] BSTR bstrRemoteFile,
[in] VARIANT varLocalFile,
[in] long nRemoteStartPosLo,
[in] long nRemoteStartPosHi,
[in] long nLocalStartPosLo,
[in] long nLocalStartPosHi,
[out, retval] enumError * retval

varLocalFile
An indicator of the local file. This may be a path to a file (String/BSTR), an IStream or any object that supports IStream.

I have re-written it like this, will see if it works on monday.

public MemoryStream GetFile(string fileName)
{
if (_Status != (int)Stat.OPEN)
{
_LastMessage = "Connection not open";
return null;
}
int nStartPosLo = 0,rStartPosLo = 0 ;
int nStartPosHi = 0, rStartPosHi = 0;
MemoryStream _strm = new MemoryStream();
_ftp.DataTransferMode = enumDataTransferMode.ftpDataTransferModeStream;
_ftp.DataProtection = enumDataProtection.ftpDataProtectionPrivate;
_ftp.DataTransferType = enumDataTransferType.ftpDataTransferTypeASCII;

err = _ftp.Download(fileName, (object)_strm, rStartPosLo, rStartPosHi, nStartPosLo, nStartPosHi);
if ( err == enumError.ftpErrorSuccess)
{
_strm.Seek(0, System.IO.SeekOrigin.Begin);
return _strm;
}
else
{
_LastMessage = MapError(err);
return null;
}

}

That won't work because the C# Stream class does not implement the COM IStream interface. What you need is a IStream to C# Stream adapter. You can find one in the SmartFTP SDK:
https://www.smartftp.com/client/features/sdk

The adapter is located at Samples\TransferQueue\C#\Download\Interop\IStreamAdapater.cs