User (Old forums)MemberJanuary 26, 2009 at 8:44 amPost count: 23064
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
Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Canestrier (had 2180 views)User (Old forums)MemberJanuary 26, 2009 at 4:55 pmPost 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.
FtpClient ftpClient = new FtpClient();
new FileTransferStatusEventHandler( ftpClient_FileTransferStatus );
ftpClient.Connect( someServer );
ftpClient.Login( username, password );
using( Stream source = new FileStream( @”D:\temp\local.txt”, FileMode.Open ) )
FtpItemInfoList list = ftpClient.GetFolderContents( “resumeFile.txt” );
source.Position = list[ 0 ].Size;
“resumeFile.txt”, true );
AbstractFile destination = new DiskFile( @”D:\temp\local.txt” );
“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)
- You must be logged in to reply to this topic.