EldoS | Feel safer!

Software components for data protection, secure storage and transfer

FTPS.Async - OnProgress

Also by EldoS: RawDisk
Access locked and protected files in Windows, read and write disks and partitions and more.
#26577
Posted: 09/24/2013 03:16:16
by Christian Hermann (Basic support level)
Joined: 09/20/2013
Posts: 17

Hello,

i want download multiple Files at the same time with: SecureBlackbox.FTPS.Async.

In my Init() i have:

Code
this.Client.OnProgress += new SBUtils.TSBProgressEvent(this.Client_OnProgress);


Here is the downloader:

Code
async Task DownloadFileAsync(Work work)
        {
            FileStream DataStream = new FileStream(work.Name, FileMode.OpenOrCreate, FileAccess.Write);
            try
            {
                FNeededIndex = 0;
                await Client.ReceiveAsync(work.Name, DataStream);
            }
            catch (Exception E)
            {
                Log(E.Message, true);
            }
            finally
            {
                DataStream.Close();
            }
        }


And here is the OnProgress Method.

Code
private void Client_OnProgress(object Sender, long Total, long Current, ref bool Cancel)
{
   if (Total > 0)
   {
      string lr = ((SBSimpleFTPS.TElSimpleFTPSClient)Sender).LastReceivedReply;
      //Upload
      if (lr.StartsWith("150 Ok to send data"))
      {
         double p = Math.Round(((double)Current * 100) / (double)Total);
      }
      //Download
      else if (lr.StartsWith("150 Opening BINARY mode data connection"))
      {
         double p = Math.Round(((double)Current * 100) / (double)Total);
      }
   }
}



No my questions:

1. Is there a better method to recognize a download or upload? At the moment i just read the LastReceivedReply.

2. When i have 5 downloads at the same time, how can i report the correct file status, to the correct progress? I miss the Filename in this OnProgresss method or something else ....


Thank you
#26578
Posted: 09/24/2013 04:25:14
by Ken Ivanov (EldoS Corp.)

Hello Christian,

TElSimpleFTPSClient only supports transfer of one file at a time (as it only deals with a single FTPS connection to the server). If you wish to transfer several files at a time, you would need to manage several FTPS connections with the use of several instances of TElSimpleFTPSClient component (that's how it is done by all FTP tools).

Taking that into account, your questions are easily resolved - you always know what operation a particular client component is performing and what exactly file is being transferred.
#26579
Posted: 09/24/2013 06:30:41
by Christian Hermann (Basic support level)
Joined: 09/20/2013
Posts: 17

Thank you :)

CLOSED

Reply

Statistics

Topic viewed 1336 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!