Solved

FTP transfer WITH progress bar?

Posted on 2004-08-16
9
534 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
9 Comments
 
LVL 3

Expert Comment

by:realrael
ID: 11817729
0
 
LVL 4

Accepted Solution

by:
Daniellus83 earned 200 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now