Help please. Simple question that has cost me a lot of sleep!

 
I'm new to this forum and hello everyone :)

My question is:
How do I specify a path in mq4 to save a file to the root directory (c:\)?
Sounds simple but I can't seem to get around it. Somehow it keeps saying that there are too many symbols (doesn't like the ":" I think).

Thanks in advance
Marty
 
Marty:
I'm new to this forum and hello everyone :)

My question is:
How do I specify a path in mq4 to save a file to the root directory (c:)?
Sounds simple but I can't seem to get around it. Somehow it keeps saying that there are too many symbols (doesn't like the ":" I think).

Thanks in advance
Marty

According to the documentation https://docs.mql4.com/files, you can't. All files reside in the expertsfiles sub directory (or the testerfiles sub directory at backtesting) of the installation directory, or a sub directory thereof.
 
richplank wrote:
Marty wrote:
I'm new to this forum and hello everyone :)

My question is:
How do I specify a path in mq4 to save a file to the root directory (c:)?
Sounds simple but I can't seem to get around it. Somehow it keeps saying that there are too many symbols (doesn't like the ":" I think).

Thanks in advance
Marty

According to the documentation https://docs.mql4.com/files, you can't. All files reside in the expertsfiles sub directory (or the testerfiles sub directory at backtesting) of the installation directory, or a sub directory thereof.

richplank,

Thanks for checking. Not what I wanted to hear (at all! LOL) but at least I know now it's not just me failing to see something obvious :)

 
You can use WinAPI functions. For example
#import "Kernel32.dll"
bool CopyFileA (string source_file, string destination_file, bool if_exist);
#import
 
int start()
  {
   if(CopyFileA("G:\\tst\\111.txt", "C:\\222.txt", 0)==false)
      Print("Copying error");
  }
 

Thanks for that :)

By the way, have you worked with ftp in mq4? I can't seem to get it to work from within an EA. Just returns nil. Apparently it can't be done from a custom indicator (and why not?) but should work from an EA. I've followed the code:

if(!SendFTP("report.txt"))
{ lasterror=GetLastError();

and it didn't work. Any idea?

stringo wrote:
You can use WinAPI functions. For example
#import "Kernel32.dll"
bool CopyFileA (string source_file, string destination_file, bool if_exist);
#import
 
int start()
  {
   if(CopyFileA("G:\\tst\\111.txt", "C:\\222.txt", 0)==false)
      Print("Copying error");
  }

 
stringo wrote:
You can use WinAPI functions. For example
#import "Kernel32.dll"
bool CopyFileA (string source_file, string destination_file, bool if_exist);
#import
 
int start()
  {
   if(CopyFileA("G:\\tst\\111.txt", "C:\\222.txt", 0)==false)
      Print("Copying error");
  }
stringo:

Didn't work. Didn't report an error message either. I've put an Alert(filecopied) ---- where filecopied was a boolean that got its value from that function----- and it didn't even give me an alert. Don't know what I'm doing wrong.

 
Did You allow dll-calls for your experts?

What errors output to experts' log?
 
Yup, I've allowed DLL calling and disabled manual confirmation (not that that matters). But when it was enabled it asked for confirmation so at least we know it's trying to call it.

Error log:
20:08:07 FTP sender GBPUSD,H1: cannot call function 'CopyFileA' from dll 'Kernel32. dll'
 
What the value returns GetLastError function after dll-call

What the operating system do You use? 
 
stringo wrote:
What the value returns GetLastError function after dll-call

What the operating system do You use?

I've used the following code:
if (!CopyFileA("\test.txt", "\test2.txt", 0))Alert(GetLastError());

There's no alert at all.

My OS is windows XP
 
20:37:44 FTP sender GBPUSD,H1: deinitialized
20:37:44 FTP sender GBPUSD,H1: loaded successfully
20:37:44 FTP sender GBPUSD,H1: initialized
20:37:45 FTP sender GBPUSD,H1: cannot call function 'CopyFileA' from dll 'Kernel32. dll'
20:37:45 FTP sender GBPUSD,H1: expert stopped


start (){

if (!CopyFileA("\test.txt", "\test2.txt", 0)){Alert(GetLastError());}



And that's all the code, except for the definition of the function (before init())

#import "Kernel32.dll"
bool CopyFileA (string source_file, string destination_file, bool if_exist);
#import
Reason: