Aspose Network FTP

I have used the demo to create an FTP download system, however, is there anyway to make a download graph appear?

Thanks.

Hi,

You can implement download graph or show download progress using the "TransferProgress" event. Below is the console based sample. You can use the "TransferProgressEventArgs" object's properties in your application to implement it.

public void DownloadFile()
{
FtpClient client = new FtpClient("ftp.microsoft.com", 21, "anonymous", "Password");
try
{
client.Connect();
client.Login();
client.TransferProgress += new TransferProgressEventHandler(client_TransferProgress);
client.Download("\\temp.data", "C:\\test.data");
}
catch (FtpException fe)
{
//Connection failed
Console.Write(fe.Message);
}
}

private static void client_TransferProgress(object sender, Aspose.Network.Ftp.TransferProgressEventArgs e)
{
Console.WriteLine("download progress:" + e.TotalTransferedBytes + " bytes");
}

Thank you for this information. However, I am doing this on my web page and I have created a java client side script to update an HTML text box with the total bytes. When I run the download, the box doesn’t update. Is there anything else that I need, or is this not possible without doing postbacks?

Hi

Since the delegate that shows the transferred bytes runs on the server (IIS), its not possible to update the browser using the above code. Because a postback is required for the browser to get the updated value of the transferredbytes variable from server.

It might be done using Ajax (Microsoft Atlas) by including the progress bar or textbox that shows the transferred bytes in the UpdatePanel. In this way, the selected controls can be updated without doing the postback.

I will look into this in detail and might be able to provide you a sample web application with download progress.