This project is read-only.

FTPS Resume Download

Mar 8, 2016 at 3:43 PM
Edited Mar 8, 2016 at 3:46 PM
Thanks for this fantastic library. It's very useful. I have added a functionality to resume downloading.
public ulong GetFile(string remoteFileName, string localFileName, FileTransferCallback transferCallback)
{
    ...

    var localFile = new FileInfo(localFileName);
    if(localFile.Exists)
    {
        using (Stream s = GetPartOfRemoteFile(remoteFileName, localFile.Length))
        {
            // file exist append, otherwise create which is the else block
            using (var fs = new FileStream(localFileName, FileMode.Append, FileAccess.Write, FileShare.None))
            {
                ...
    }
    else
    {
        ...
    }
    ....
}
plus you will need this function
private FTPStream GetPartOfRemoteFile(string remoteFileName, long offset)
{
    SetupDataConnection();
    RestCmd(offset);
    RetrCmd(remoteFileName);
    return EndStreamCommand(FTPStream.EAllowedOperation.Read);
}
as well as a Resume command
private void RestCmd(long offset)
{
    HandleCmd($"REST {offset}");
}
May 17, 2016 at 12:57 PM
Edited May 17, 2016 at 1:01 PM
Hi,

I am new to this dll. I want to pause and resume files on ftp server using this dll.
I have a requirement that, once download has started and lets say it is 20% completed, then the power failure occurs or internet got down. Then, when he starts downloading the same file, then it should resume from 20% instead of 0%.
All this i need to show in a progress bar in one of my project.
Can you tell me how to use this dll to accomplish this ?


Thanks
Amit Agrawal
May 17, 2016 at 2:17 PM
All you need it above :)
May 18, 2016 at 6:48 AM
Do you have an example source code for it ?
If you can post it, that would be really helpful because i am not able to use this feature from the dll.


Thanks again
Amit Agrawal