- Progress of file transfer
- Frequency of the event
In french: NetRecupereFichier
Retrieves an existing file from an FTP server (File Transfer Protocol) powered by WINDEV. The file is retrieved by the client computer.
: To allow (or not) the use of this function on an FTP/RPC server, call NetServerOption
// -- Code of button for file retrieval
IF NetGetFile(ConnectFTP, "C:\autoexec.bat", "C:\autoexec.cli", ...
WM_MYMESSAGE, 10) = False THEN
Error("Error while transferring the file")
<Result> = NetGetFile(<Connection identifier> , <File on server> , <File on client computer> [, <Event> [, <Event frequency>]])
The function immediately returns a status report and the transfer is performed in parallel in another Windows task
- True if the transfer was performed,
- False otherwise.
<Connection identifier>: Integer
Connection identifier (returned by NetConnect).
<File on server>: ANSI character string
Full name (name and path) of file to copy, found on the server.
<File on client computer>: ANSI character string
Full name (name and path) of file copied onto the client computer.
<Event>: Character string or integer (optional)
Custom event or Windows event sent to the client to follow the progress of the transfer (see the Notes).
<Event frequency>: Optional integer
Frequency (in percentage of the size of the file) at which the <Event> message is sent to the client.
Progress of file transfer
The progress of the file transfer is managed in the FTP client program only.
NetGetFile is not a blocking function: the file transfer is performed in background task. However, you have the ability to transfer a single file at a time.
To transfer several files, you must wait for each file to be transferred before transferring the next one.
In this case, two parameters can be used with NetGetFile:
- a progression message (<Event> parameter),
- a frequency (<Event frequency> parameter).
sends the specified message to follow the progress of transfer. This message must be intercepted by Event
. The message contains two parameters:
- _EVE.wParam indicates the transfered size (progress indicator),
- _EVE.lParam indicates the total size of the file.
The progress message is processed in the procedure called by Event
. In this procedure, you can:
- display a progress bar by using the parameters of the message (_EVE.lParam and _EVE.wParam),
- find out whether file transfer is completed (in this case, _EVE.lParam = _EVE.wParam).
<Event frequency> is used to define the minimum frequency for sending messages. For example, for a 1 MB file and a 10% frequency, a message will be received whenever 100 KB are transferred.
The frequency defines the maximum number of messages that can be received. The number of messages received is reduced when the transfer is fast.
For example, for a 100KB file and a 10% frequency, about 10 messages will be received: 1 message whenever 10 KB are transferred. In fact, the number of messages will be less because the transfer is fast.
Tips regarding the choice of frequency:
- If no progression bar is displayed, the best choice for the frequency is set to 100%: A single message will be received when the file transfer is completed.
- If the transfer rate is slow (transfer by modem for instance), we recommend that you display a progress bar. A frequency of 10% is appropriate in most cases.
- If the transfer rate is fast (local network for instance), we do not recommend that you use a small frequency (1% for example) because the volume of messages received could saturate the system. In this case, a frequency of 10% is appropriate in most cases.
This page is also available for…