Download / upload files using a vb ftp program ....
I needed a way to ftp files to or upload / download files to a web server on a scheduled basis.
I have some web pages on my local computer which are regularly created and modified. Those files then have to be transferred to the web server using ftp. I also have log files on the web server which I want to download to my PC each day so that they can be processed by another program.
VBFTP is a visual basic ftp program intended to automate the upload and download process using a text batch file to store the details. The vb program can then be run from a scheduler in XP or Windows 2000.
The source code is provided and may be used or modified as required.
The program
VBFTP uses the Microsoft INET component for the ftp (MSINET.OCX) which is installed as part of Visual Basic 6. It also needs the Microsoft Access Object Library (MSACC9.OLB) which is used for some of the file manipulation commands.
If these files are not on your computer then you will have to register them.
The text file
All the details needed by the vb ftp program are stored within a text file which is called vbftp.txt by default, and has to be located in the same directory as the executable vbftp.exe.
If you wish to use the program from the command line you can create as many .txt files as you like and call them whatever you like. The visual basic ftp program can then executed from the command line by :
vbftp.exe filename
where 'filename' is the full file name and path of the text file.
Log file
A log files is generated every time the program is run called logfile.txt. The file is located in the same directory as the vbftp.exe program
Supported commands
The following commands are used in the .txt file:
Comments are defined by placing # at the start of the line :
Request time out identifies the time in seconds before the command times out.
URL defines the ftp address of the web server.
Protocol needs to be set to icFTP in this situation.
Remote port is the ftp port of the web server and is usually 21.
User name is the name for ftp access to the web server
Password is the corresponding password for the ftp user.
Get a single file from the remote server to the local computer.
Put a single file from the local computer to the remote computer.
Put the contents of a local directory to a remote directory.
Gets the files from the server which are different to the files on the local drive so that the remote and local files are same. It does not delete the local files, it only deletes them when the file size is different.
Close the current ftp connection.
The end command exits the VB program and is placed at the end of the commands. This command is only relevant when the program is run from the command line.
| Copyright © 2007 | Page updated July 2007 |