Wininet FTP

 

I've been trying to figure this out for some time now and i've been searing everything to find a solution. I'm trying to use the Wininet function FtpGetCurrentDirectioryA. According to MSDN

C++

BOOL FtpGetCurrentDirectory(
  _In_     HINTERNET hConnect,
  _Out_    LPTSTR lpszCurrentDirectory,
  _Inout_  LPDWORD lpdwCurrentDirectory
);

 I have the first variable hConnect correct because I am able to open the connection and Login to my ftp server but when I try to FtpGetCurrentDirectory it fails. I have the declarations in a separate .mqh file

#import "wininet.dll"
   int InternetOpenA(string lpszAgent, int dwAccessType, string &lpszProxyName, string &lpszProxyBypass, int dwFlags);
   int InternetConnectA(int hInternet, string lpszServerName, int nServerPort, string lpszUsername, string lpszPassword, int dwService, int dwFlags, int dwContext);
   bool InternetGetLastResponseInfoA(int &lpdwError, string lpszBuffer, int &lpdwBufferLength);
   int FtpCommandA(int hConnect, bool fExpectResponse, string dwFlags, string& lpszCommand, string& dwContext);
   bool FtpSetCurrentDirectoryA(int hInternet, string lpszDirectory);
   bool FtpGetCurrentDirectoryA(int hInternet, string lpszCurrentDirectory, int lpdwCurrentDirectory);
   bool FtpGetFileA(int hConnect, string lpszRemoteFile, string lpszNewFile, bool fFailIfExists, string dwFlagsAndAttributes, string dwFlags, int dwContext);
   bool InternetCloseHandle(int hInternet);
#import

 Anyone have an idea where I going wrong. I've tried

 bool FtpGetCurrentDirectoryA(int hInternet, string lpszCurrentDirectory, int lpdwCurrentDirectory);
 bool FtpGetCurrentDirectoryA(int hInternet, string lpszCurrentDirectory, int &lpdwCurrentDirectory);
 bool FtpGetCurrentDirectoryA(int hInternet, string &lpszCurrentDirectory, int &lpdwCurrentDirectory);
 bool FtpGetCurrentDirectoryA(int hInternet, string lpszCurrentDirectory, int &lpdwCurrentDirectory[]);
 bool FtpGetCurrentDirectoryA(int hInternet, string &lpszCurrentDirectory[], int &lpdwCurrentDirectory[]);

when I try to use the arrays MT4 platform just crashes or says invalid address for lpdwCurrentDirectory

 I'm a bit ashamed to admit it but it took me 3 days to figure out that this wouldn't work unless it was set as an EA and not an indicator. LOL. (Go ahead laugh its ok). I knew better though. In case your wondering this is for a history file that is generated on a VPS and i'm trying to download it. Oh, and i'd be more than happy to provide the code for this once it's complete so it may assist someone else in the future. Thanks for the help in advance

 
so you are trying to write a .hst file over FTP to your own PC from your VPS, right? Why not run a cronjob on the VPS to trigger a .bat or .sh ? Less work, better performance, less complex thus less errors.
 
Russell:
so you are trying to write a .hst file over FTP to your own PC from your VPS, right? Why not run a cronjob on the VPS to trigger a .bat or .sh ? Less work, better performance, less complex thus less errors.


well the VPS is responsible for collecting ticks and creating the tick files. I have an indicator that creates the tick charts once the tick file has arrived and continues collecting tick data. This will at most be retrieved once a day.

This is the only thing standing in my way.