FTP transfer WITH progress bar?

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!
dudinatrixAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Daniellus83Connect With a Mentor Commented:

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
 
realraelCommented:
0
 
dudinatrixAuthor Commented:
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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

 
Daniellus83Commented:

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
 
Legolas2003Commented:
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
 
Daniellus83Commented:

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
 
Daniellus83Commented:
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
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.