Re: Problem with FTP
- Posted by jimcbrown (admin) Jan 12, 2010
- 1393 views
SergioGelli said...
system("start /b ftp "&ftp_url_to_download&", 2) The program can find out if the operation is over?
No, not directly. If you know the size of the file being downloaded though then you can simply do a dir() on the file to find out if it is done yet or not.
Otherwise, the following batch script provides a work-around:
@echo off rem Lets assume this batch script is named ftpbatch.bat rem Usage: ftpbatch.bat ftp://site.tld/file/to/get c:\temp\ok_download_is_done.txt ftp "%1" echo %ERRORLEVEL% > "%2"
and then you would do
system("start /b ftpbatch.bat "&ftp_url_to_download&" "&completion_file, 2)
Then you could do a dir() on completion_file, and when it is created you know the ftp download is finished. (And if you need to see the exit code of ftp.exe to know if the download was successful or aborted, you can read the exit code in the file.)