thepaulguy Posted February 24, 2012 Share Posted February 24, 2012 (edited) Is there a way to measure how many bytes have been downloaded when using _FTP_FileGet? I am trying to get a working Progress bar that actually displays progress. I tried using the _FTP_ProgressDownload but it doesn't seem to read the progress in real time. The progress bar sits at 0 unitl the download is finished then it goes to 100%. So far this is what I have BUT the progress bar won't update until I actually open the folder in explorer and hit refresh (F5). O.o Huh? Anyway... It's in two files. I would love some help on this one because it's driving me nuts. TEST1.EXE #include <FTPEx.au3> $latestversion = "1" $server = "localhost" $port = 7227 $Open = _FTP_Open('MyFTP Control') $Conn = _FTP_Connect($Open, $server, "USERNAME", "PASSWORD", 1, $port) $sFileSize = _FTP_FileGetSize($Conn, "800MBFILE.EXE") _FTP_Close($Open) ProgressOn("800MBFILE", "Downloading " & "800MBFILE " & $LatestVersion & "...", "0%", 0, 0) $_Pid = Run("test2.exe") $Pct = 0 While ProcessExists ($_Pid) If $Pct = 100 Then ExitLoop Sleep(500) ;Sleep for half a second to avoid flicker in the progress bar $BytesReceived = FileGetSize(@TempDir & "800MBFILE.EXE") ;Get bytes received $Pct = Int($BytesReceived / $sFileSize * 100) ;Calculate percentage ProgressSet($Pct, $Pct & "%") ;Set progress bar WEnd ProgressSet(100,"Download Complete!") Sleep(2000) ProgressOff() _FTP_Close($Open) and TEST2.EXE #include <FTPEx.au3> $server = "localhost" $port = 7227 $Open = _FTP_Open('MyFTP Control') $Conn = _FTP_Connect($Open, $server, "USERNAME", "PASSWORD", 1, $port) _FTP_FileGet($Conn, "800MBFILE.EXE", @TempDir & "800MBFILE.EXE") _FTP_Close($Open) Edited February 24, 2012 by thepaulguy Link to comment Share on other sites More sharing options...
Mikeman27294 Posted February 24, 2012 Share Posted February 24, 2012 Look into this:_FTP_ProgressDownload Link to comment Share on other sites More sharing options...
thepaulguy Posted February 25, 2012 Author Share Posted February 25, 2012 Thanks for the response but you must not have read my post ....... I did work with that and it didnt work as expected either. Link to comment Share on other sites More sharing options...
Beege Posted February 25, 2012 Share Posted February 25, 2012 (edited) The data is held in a buffer/temporary file until its finshed. Thats why it goes from 0 to 100 so fast. Its possible to get byte progress using _FTP_SetStatusCallback() but it can get a little tricky. _FTP_ProgressDownload() is certainly the easy route. There might have been something wrong in your script if you want to post whatever you tried before. Edited February 25, 2012 by Beege Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator Link to comment Share on other sites More sharing options...
thepaulguy Posted February 29, 2012 Author Share Posted February 29, 2012 I went with this instead of the FTPex.au3. $LatestVersion=1 $Protocol="ftp" $server = "localhost" $port = 7227 ProgressOn("800MBFILE", "Downloading " & "800MBFILE " & $LatestVersion & "...", "0%") $url = $Protocol & "://USERNAME:PASSWORD@" & $Server & ":" & $Port & "/800MBFILE.EXE";Set URL Local $hDownload = InetGet($url, @TempDir & "800MBFILE.EXE", 1, 1) $FileSize = InetGetSize($url) ;Get file size While Not InetGetInfo($hDownload, 2) ;Loop until download is finished Sleep(500) ;Sleep for half a second to avoid flicker in the progress bar $BytesReceived = InetGetInfo($hDownload, 0) ;Get bytes received $Pct = Int($BytesReceived / $FileSize * 100) ;Calculate percentage ProgressSet($Pct, $Pct & "%") ;Set progress bar WEnd ProgressSet(100,"Download Complete!") Sleep(2000) ProgressOff() InetClose($hDownload) Link to comment Share on other sites More sharing options...
ElwoodB Posted October 11, 2023 Share Posted October 11, 2023 On 2/29/2012 at 11:28 PM, thepaulguy said: ... While Not InetGetInfo($hDownload, 2) ;Loop until download is finished ... it is a bad habit to use values instead of "understandable" names, here "2" instead of $INET_DOWNLOADCOMPLETE. Unless you want to lose time by reading your code again. Back to topic: The code you propose here doesn't work for me. I find two issues: 1) I can see 2 connections to my FTP server, one done by InetGet and one done by InetGetSize. This is strange (I would expect the 2 to use the same connection) but as InetGetSize does not use a connection handle I guess it's by design. Then, I see the 2 connections staying idle for 2 minutes and then they disconnect from the server with error: 425 Error while transfering data: ECONNABORTED - Connection aborted 2) If I use first InetGetSize and then InetGet, I have only one connection, instead of two. It makes me think there is some tricky stuff here. If I use Example 1 from the help page of _FTP_ProgressDownload, it works perfectly, even the progress bar. So this is the way to go, IMO. PhilippeAmiga user Link to comment Share on other sites More sharing options...
Developers Jos Posted October 11, 2023 Developers Share Posted October 11, 2023 Wisdom after 11 years? Andreik 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
ElwoodB Posted October 20, 2023 Share Posted October 20, 2023 Better late than never 😉 PhilippeAmiga user Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now