Nil*_*ert 0 c++ ftp binary libcurl transfer
我正在使用libcurl使用FTP传输二进制文件(.exe),并将其保存到本地文件.问题是文件传输后,它被更改,不再是有效的Win32应用程序,并且不会运行.我是这样做的:
CURL *curl;
curl = curl_easy_init();
FILE* f = fopen("C:\\blah.exe", "w");
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "ftp://ftp.mysite.com");
curl_easy_setopt(curl, CURLOPT_USERPWD, "blah:blah");
curl_easy_setopt(curl, CURLOPT_FTP_FILEMETHOD, CURLFTPMETHOD_SINGLECWD);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &f);
} else {
fclose(f);
return CURL_EASY_INIT_FAIL;
}
fclose(f);
Run Code Online (Sandbox Code Playgroud)
该文件已写入,但比FTP服务器上的文件大.就像我说的,尝试运行它会导致"%1不是有效的Win32应用程序"错误.我忘了设置选项还是什么?