Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

FTP transfer WITH progress bar?

Posted on 2004-08-16
9
Medium Priority
?
581 Views
Last Modified: 2009-07-29
I need to do a built in FTP transfer (both an Upload and a Download) in my vb.net app.. and would like both of them to show a progress bar as the file transfers.

I've got a few ways to do the transfer itself, but I have no idea how to make it update the progress bar WHILE it's updating.

Any help?  The more information as you can give, the better!
0
Comment
Question by:dudinatrix
7 Comments
 
LVL 3

Expert Comment

by:realrael
ID: 11817729
0
 
LVL 4

Accepted Solution

by:
Daniellus83 earned 800 total points
ID: 11818591

Dear dudinatrix,

here you have a better link, since realreal provided one with only VB6. This one is gives you some:

http://www.aspfree.com/c/a/Code%20Examples/Building-a-Basic-FTP-Client-with-VSNet-by-Lance-R

Down the page there is a section:

------
Percent Transferred
 

OK, so now we are transferring files. How do I know the status of the file transfer? First of all, when the transfer is first begun, a StartTransfer event will fire. During the transfer, a Transfer event will fire, and after the transfer is finished, an EndTransfer event will fire. You can use the BytesTransferred property that is available in the Transfer event of the FTP component to keep track of how many bytes have been transferred so far in the current transfer. This information will allow you to create a progress bar. In order to do the math, you will of course need to know the file size. If you are uploading a file to the server, you already know the file size since its local (Use a File system object). If you are downloading a remote file from the server, you’ll need to ask the server how large the file is before initiating the download, by setting the RemoteFile property to the appropriate file and issuing a ListDirectoryLong. Then the DirList event will be fired once for the file you have specified and you can get the filesize parameter of the DirList event.
------

you asked how you could keep track of the update.

I do not know exactly how your code looks like, but try this:

> make sure the ftp works.
> put a progressbar on your form, lets call it progressbar1
> define a variable where the filesize can be stored:  (put this outside any sub)

dim _filesize as long

> put a TIMER on your form, and activate it when the STARTTRANSFER event is fire":

 Private Sub Ftp1_OnDirList(...........) Handles Ftp1.Starttransfer   '<< you might need to change this
  'Timer settings
  Timer1.Enabled
  Timer1.Interval = 200   'a tick every 200 millisec
  Timer1.Start()

  'Progressbar settings
  progressbar1.minimum = 0
  progressbar1.maximum = 100
  progressbar1.step = 1
  progressbar1.value = 0

  'Get the filesize being transferred:   '<< I am not sure how to get the filesize,.. but that should not be the problem for you
   _filesize = ftp1.localfile.filesize '???

 End Sub


> Then we gonna update the progressbvar every time the timer ticks:

   Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
     dim progressvalue as integer
     progressvalue = Cint(ftp1.BytesTransferred/_filesize)
     if progressvalue < 0 then
          progressvalue = 0
     elseif progressvalue > 100
          progressvalue = 100
     else
         ' the value is correct and may be passed to the progressbar
     end if  
     progressbar1.value = progressvalue
  End Sub


As you see, you might have to change 2 things to get it properly working, but I hope I gave you the good idea

Try it and maybe you like it!

Daniël
0
 

Author Comment

by:dudinatrix
ID: 11820875
realrael: Thank you, but like Daniël said, I'm looking for a VB.net specific solution rather than VB6.

Daniël:  Thank you VERY much for the detailed post, I really do appreciate it... however, I'm sorry to say that it requires downloading a third party FTP component.. and while it's free, I assume their name will be all over it in my source code and possibly the application itself.  I'd use it if it were for my own use, but I'm writing an application for my company, and would prefer it with no third party references.  Your post did give me a better idea on how to work with the the progress bar during the transfer , so thank you!
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:Daniellus83
ID: 11821022

Sorry, but I really didn't do the post to give you any source.. I posted this one detailed on the fact that your have already build your own FTP interface... ("...I've got a few ways to do the transfer itself...")

I though you only needed to add good interface wich handles the progressbar etc...

Am I right?... My posted code doesn't  depend on the 3rd party software/sourcecode...

0
 

Expert Comment

by:Legolas2003
ID: 11821040
Go to this URL: http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=DD5E4A38-7F5B-45E0-9C36-64B987947C20

this is a great component.
If you have problems contact me...
Regards
0
 
LVL 4

Expert Comment

by:Daniellus83
ID: 11821106

Okay as I cannot give up:

Here you have a (full) FTP library WITHOUT references!!

>> http://www.codeproject.com/dotnet/dotnetftp.asp?df=100&forumid=3824&exp=0&select=591722


This with the other post should complete the answer?  ;-)
0
 
LVL 4

Expert Comment

by:Daniellus83
ID: 12110314
TheLearnedOne:

realreal didn't post any usefull code since it was only VB6, not really this section I guess...:

(post @ 04:31PM CEST)   "...realrael: Thank you, but like Daniël said, I'm looking for a VB.net specific solution rather than VB6...."
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question