Opens a file on a remote server.
WebAPI.bdh
WebFtpOpenFile(in hFtp : number, in sFile : string, in bBinaryTransfer : boolean, in bWriteMode : boolean): boolean;
true if successful
false otherwise
Parameter | Description |
---|---|
hFtp | Valid handle to an FTP session. This handle must have been returned from a previous call to WebFtpConnect. |
sFile | Target filename |
bBinaryTransfer |
If set to true, the file is opened for using FTP's Image (Type I) transfer method. The file is written and read exactly as it exists with no changes. This is the default transfer method. If set to false, FTP's ASCII (Type A) transfer method is used for reading and writing. Control and formatting information is converted to local equivalents. |
bWriteMode |
Specifies whether a file is opened for writing or reading purpose. If this parameter is set to true, the file is opened in write mode. In this case, the previous file content is overwritten. Otherwise, the file is opened for reading purpose. |
dcltrans transaction TWriteFile var hFtp : number; sData : string(50); nData : number; // number of bytes written begin sData := "Hello world!"; WebFtpConnect(hFtp, "localhost", WEB_PORT_FTP, "user", "pass"); WebFtpOpenFile(hFtp, "testfile.txt", false, true); WebFtpWriteFile(hFtp, sData, Strlen(sData), nData); write(nData); write(" bytes written"); writeln; WebFtpCloseFile(hFtp); WebFtpShutdown(hFtp); end TWriteFile;