URGENT:How to implement a Progress Bar during FTP.

Hi Experts,

I want a progress bar should be displayed while File Transfer.

Also I need to step the Progress bar relative to the transfer rate during FTP.

Who is Participating?

Improve company productivity with a Business Account.Sign Up

umaramaConnect With a Mentor Commented:
Say you have five files to download. A-300KB B-200KB C-100KB D-600KB and E-450KB. Currently your progress ctrl increments 5 times. And you wish to indicate to the user how much out of (300+200+100+600+450 = 1650KB) you have downloaded. Hence you are mentioning that you need to implement the Progress Bar by calculating the Transfer rate.(ie kb/sec). Yes ?

If what I understood is correct, then the solution involves you not to use GetFile() or PutFile() which does all the work for you. You take the extra trouble of using OpenFile() which gives you the CInternetFile.

Taken from Documentation of OpenFile ....
"Use OpenFile when
An application needs a fine level of control over a file transfer. For example, the application may want to display a progress control indicate the progress of the file transfer status while downloading a file.
After calling OpenFile and until calling Close, the application can only call CInternetFile::Read, CInternetFile::Write, Close, or CFtpFileFind::FindFile. Calls to other FTP functions for the same FTP session will fail and set the error code to FTP_ETRANSFER_IN_PROGRESS. "

Do read the rest of the documentation. Let me know if this solves your problem.

Are you using CFtpConnection ? Or you have your own class to FTP?

Are you downloading or uploading the file ? Basically, do you know what is the size of the file you are working with ?

Working with CProgressCtrl is very easy once you have the desired range. As for FTP, you can work with callbacks to get the size of file downloaded/uploaded. This info can be used to increment the position of progress ctrl.

lakshmi083198Author Commented:
Thanks Uma,

Yes I am using CFtpConnection.

I am Uploading and Downloading files.

Actually I have implemented progressBar by specifying its range as the total number of files to be Down/up loaded and stepping once after each file has been transfered.
But I need to implement the Progress Bar by calculating the Transfer rate.(ie kb/sec).

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Hi Lakshmi..

  I think u need to find the data transfer rate actually. say file xx.cpp 25 % send at 4000 bytes/sec . AM i right ? The first thing is that it will vary a lot during the transmission. As u know t will depeneds upon the network traffic . Actually i haven't used with CFtpConnection .But i used WININET function which are same .You can specify a call back function in which it will give the data transfered etc.. By including a variable for time and computing the difference between each time the callback fn occurs u can easily calculate the time . To get more accurate results u have to go down to socket level but u have to implement the ftp using the help of relevant RFC .It will be more steady .

 If u cna give me u'r email ID i can give u a sample program to do this..
                            *********** Best of luck ************

Dear lakshmi,

just i am giving my idea.
0. start the downloading of required file abc.txt . and set the timer to 0.
1. in equal intervals find the size of file abc.txt.
2. comapare with original size and find the rate of transfer rate.
3. according to that set the progress bar.

with regards,
Bhavani P Polimetla.

I use GetFile()   and would like to implement a progress bar But I want to show progress for each individual file (one at a time).  I can't seem to figure it out!! Can someone send me an example of how to do this?!!  Thanks
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.