Home Forums .NET libraries Xceed SFTP/FTP for .NET Fonctionnalities about your FTP .net library

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

    Hello,

    Some days ago I post a question on ActiveX forum about resume FTP transfer (the file size was limited). The anwser was there is a possibility with .net library. Before I post this I have search resume (community search) and the latest conversation about it was from 2007 (2 years), I have
    also see the send method, and nothing (for me) can be able to resume the transfer with an offset (as I found in the active x library).

    I have try now for 2 library (xceed, chilkat), i am ok to restart my code with another library but before it’s necessary to be sure about this points :

    it’s possible :

    – to resume upload async or not async transfer for huge file (restart for 60 GO for example),
    – to resume download async or not async transfer for huge file (restart for 60 GO for example),
    – to limit the upload and the donwload rate,
    – to have information about the transfer running (rate,byte send, …..)

    Thank a lot for your answer

    Vincent

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

    User (Old forums)
    Member
    Post count: 23064

    Resuming an upload or a download is something easily implemented, which the code snippet below demonstrates.  It is not possible to limit the transfer rate, but you can handle events to have byte progression, again as shown in the code below.

    e.g.:

    FtpClient ftpClient = new FtpClient();

    ftpClient.FileTransferStatus +=

    new FileTransferStatusEventHandler( ftpClient_FileTransferStatus );

    ftpClient.Connect( someServer );

    ftpClient.Login( username, password );

    //upload

    using( Stream source = new FileStream( @”D:\temp\local.txt”, FileMode.Open ) )

    {

        FtpItemInfoList list = ftpClient.GetFolderContents( “resumeFile.txt” );

        source.Position = list[ 0 ].Size;

        ftpClient.SendFile( source,

    “resumeFile.txt”, true );

    }

    //download

    AbstractFile destination = new DiskFile( @”D:\temp\local.txt” );

    ftpClient.ReceiveFile(

    “resumeFile.txt”, destination.Size, destination.FullName, true );

     

    static void ftpClient_FileTransferStatus( object sender, FileTransferStatusEventArgs e )

    {

    //you can use the e.BytesPercent to feed a progress bar for example.

    }

    Basically, to resume sending a file, you must open a stream on that file, seek to the proper offset, then pass that stream to the SendFile overload that takes a Stream instead of a filename. Transfer will continue at that stream’s position.  To get the offset, you can verify the size of file on the server with the help of the GetFolderContents() method.

    To resume receiving a file, it is even easier, you need to get a handle on the local file, verify its size, and use the ReceiveFile overload that takes an offset, and the server will start downloading the file from the specified offset.

     

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by André (had 2778 views)

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