Hi,
I have one simple code as below:
#include "stdafx.h"
#include <stdio.h>
#include <conio.h>
#include <iostream>
#include <string>
#include <iostream>
#include <fstream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <windows.h>
#include <wininet.h>
#include <winnt.h>
using namespace std;
int main() {
//LPCTSTR server = _T("ftp.fxturn.com/public_html/data");
LPCTSTR server = _T("www.www.com");
LPCTSTR path = _T("/public_html/data");
INTERNET_PORT port = INTERNET_DEFAULT_FTP_PORT;
LPCTSTR user = _T("user");
LPCTSTR pass = _T("pass");
DWORD service = INTERNET_SERVICE_FTP;
DWORD context = 0;
LPCTSTR szLocalFile = _T("C:\\files\\a.csv");
LPCTSTR szRemoteFile = _T("reza444");
HINTERNET hSession = InternetOpen(0, INTERNET_OPEN_TYPE_PRECONFIG, 0, 0, 0);
HINTERNET hService = InternetConnect(hSession, server, INTERNET_DEFAULT_FTP_PORT, user, pass, INTERNET_SERVICE_FTP, 0, 0);
FtpSetCurrentDirectory(hService, path);
if(!FtpPutFile(hService, szLocalFile, szRemoteFile, FTP_TRANSFER_TYPE_BINARY, 0)) cout<<"False";
InternetCloseHandle(hService);
InternetCloseHandle(hSession);
MessageBox(NULL,szLocalFile,0,0);
getch();
return 0;
}
My code in this type works correctly and ftp my file very good.
But When I try use this code in another my projects that is one dll not works correctly and only create file and not ftp content of file.
In my dll I used that as one void function.
#include "stdafx.h"
#include <stdio.h>
#include <conio.h>
#include <iostream>
#include <string>
#include <iostream>
#include <fstream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <windows.h>
#include <wininet.h>
#include <winnt.h>
using namespace std;
void ftp() {
//LPCTSTR server = _T("ftp.fxturn.com/public_html/data");
LPCTSTR server = _T("www.www.com");
LPCTSTR path = _T("/public_html/data");
INTERNET_PORT port = INTERNET_DEFAULT_FTP_PORT;
LPCTSTR user = _T("user");
LPCTSTR pass = _T("pass");
DWORD service = INTERNET_SERVICE_FTP;
DWORD context = 0;
LPCTSTR szLocalFile = _T("C:\\Program Files (x86)\\MetaTrader - Alpari UK\\experts\\files\\a.csv");
LPCTSTR szRemoteFile = _T("reza444");
HINTERNET hSession = InternetOpen(0, INTERNET_OPEN_TYPE_PRECONFIG, 0, 0, 0);
HINTERNET hService = InternetConnect(hSession, server, INTERNET_DEFAULT_FTP_PORT, user, pass, INTERNET_SERVICE_FTP, 0, 0);
FtpSetCurrentDirectory(hService, path);
if(!FtpPutFile(hService, szLocalFile, szRemoteFile, FTP_TRANSFER_TYPE_BINARY, 0)) cout<<"False";
InternetCloseHandle(hService);
InternetCloseHandle(hSession);
}
Please help for find problem.
Regards,