SendFTP
SendFTP
在地址中发送文件,指定在Publisher窗口中。
bool SendFTP(
string filename, // 通过ftp发送的文件
string ftp_path=NULL // ftp服务器上传的文件
);参量
- filename
[in] 发送文件名称
- ftp_path=NULL
[in] FTP目录,如果目录未标明,直接在使用设置中描述
返回值
错误返回是“false”。
注释
发送文件应该在 terminal_directory\MQL5\files 或子文件夹中保存,如果在设置中未标明FTP地址或者访问密码,无法发送。
SendFTP() 函数在策略测试中不工作。
示例:
//+------------------------------------------------------------------+
//| SendFTP.mq5 |
//| Copyright 2024, MetaQuotes Ltd. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2024, MetaQuotes Ltd."
#property link "https://www.mql5.com
#property version "1.00"
#define FILENAME "SomeFile.bin"
#define PATH NULL
//+------------------------------------------------------------------+
//| 脚本程序起始函数 |
//+------------------------------------------------------------------+
void OnStart(void)
{
//--- 检查从终端中发送文件至 FTP 地址的许可
if(!TerminalInfoInteger(TERMINAL_FTP_ENABLED))
{
Print("Error. The client terminal does not have permission to send messages to the FTP-address");
return;
}
//--- 发送文件
ResetLastError();
if(!SendFTP(FILENAME, PATH))
Print("SendFTP() failed. Error ",GetLastError());
}