Home Forums .NET libraries Xceed SFTP/FTP for .NET Problem with BeginGetDownloadStream

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #20723 |

    I am having some problems with downloading an Async Stream. I immediatly get a call to the callback function.

    A second question, how do I set the memory stream? I have a custom memory stream that I want to use.

    Here is my code:

    ======================================================

    public void GetFile(string filename)
    {
    if (connected)
    {
    memStream.StartRate();
    gettingFtpFile = true;
    ar = http://ftp.BeginGetDownloadStream(filename,new AsyncCallback (DownloadFinished),asyncstate);
    eof = false;
    }
    }

    private void DownloadFinished(IAsyncResult ar)
    {
    //memStream.Close();
    memStream.DebugWriteLine(“Download Complete!”);
    gettingFtpFile = false;
    http://ftp.EndGetDownloadStream(ar);
    eof = true;
    if (autoDisconnect)
    Disconnect();
    }

    =================================================

    And here is the command send and reply received. (my login and password removed)

    =================================================

    Command Sent: USER xxxx
    Reply Received: 331 Password required for xxxx.

    Command Sent: PASS yyyy
    Reply Received: 230 User xxxx logged in.

    Command Sent: CWD ftp
    Reply Received: 250 CWD command successful.

    Command Sent: TYPE I
    Reply Received: 200 Type set to I.

    Command Sent: PASV
    Reply Received: 227 Entering Passive Mode (66,201,73,173,13,195).

    Command Sent: RETR music2.mp3
    Reply Received: 125 Data connection already open; Transfer starting.

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by treyweaver (had 3083 views)

    User (Old forums)
    Member
    Post count: 23064

    GetDownloadStream returns a direct NetworkStream on the file to download. Once you have that stream, it’s your job to read data from that stream and write it where you want, for example in a MemoryStream.

    BeginGetDownloadStream and EndGetDownloadStream are the async version of GetDownloadStream. Thus upon <b>completion</b>, calling EndDownloadStream will return you the NetworkStream you can read from. So it’s perfectly normal BeginDownloadStream completes so fast, it’s only the beginning of the file transfer.

    May I ask why you need to call the async version of GetDownloadStream?

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Martin (had 236 views)

    User (Old forums)
    Member
    Post count: 23064

    Hmm, many not work for us then.

    We were working with the Indy Components on a .Net Application and we need to have a custom memory stream that will get data from a FTP server. As the buffer in the memory stream gets close to full we need to slow down the ftp delivery. We slow it down by delaying the Write command on the memory stream. We need for it to be async so that that delay will not slow the application down.

    But, since you cannot use a custom memory scheme this approch will not work. Do you have any other suggestions. Our buffer in our memory stream is 4 Megbytes where the data we are downloading could approch 120 Megbytes, (in a few cases). So the memory stream cannot hold all the data.

    We have got this to run correctly on Indy and Rebex but we were trying to get it to work on some more main-stream product.

    Thanks,

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by treyweaver (had 3790 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.