In my program, I often meet a problem that the file downloading stops there because of many reasons. At this case, the whole file has to re-download in another running of the download code.
As we known that, the edtFTPnet.dll supports the resume transfer if the transfer is broken using FTPConnection.ResumeNextTransfer Method. But I don't know exactly how to use this ResumeNextTransfer method? How to test the ResumeNextTransfer is working? Can you please give me sample codes to explain how to use the this method to resume the transfer?
Below code is my example, please help check the problem it has.
private void button1_Click(object sender, EventArgs e)
{
try
{
ftpConnection.ServerAddress = "xx.xx.xx.xx";
ftpConnection.UserName = "xxxxx";
ftpConnection.Password = "xxxxx";
ftpConnection.CommandEncoding = Encoding.GetEncoding("GB2312");
ftpConnection.ConnectMode = FTPConnectMode.PASV;
ftpConnection.TransferType = FTPTransferType.BINARY;
ftpConnection.Connect();
string[] filelist = ftpConnection.GetFiles();
if (ftpConnection.Exists("38384032.rmvb"))
{
ftpConnection.DownloadFile("d:\\38384032.rmvb", "38384032");
}
}
catch (FTPException ftp)
{
ftpConnection.ResumeNextTransfer();
}
catch (Exception ex)
{
}
finally
{
ftpConnection.Close();
}