How do I use the ShellExecuteW copy command?

 

I'm trying to copy a file on my C: drive from mql4.  I cannot use the inbuilt mql4 FileCopy command as the file I want to copy is not within the metatrader folders.

Here is my test code, but it's not working.  Any help would be much appreciated?

 

#import "shell32.dll"
  int ShellExecuteW(int hwnd,string Operation,string File,string Parameters,string Directory,int ShowCmd);
#import
ShellExecuteW (NULL, "open", "cmd", "/c copy /Y a.txt b.txt", "c:\\", NULL);
 

Use CopyFileW for copying instead. Moreover, unlike ShellExecurte it is synchronous.

 

Thanks heaps.  Here's some working examples of both methods:

#import "shell32.dll"
  int ShellExecuteW(int hwnd,string Operation,string File,string Parameters,string Directory,int ShowCmd);
#import

string src_path = TerminalInfoString(TERMINAL_DATA_PATH)+"\\MQL4\\Files\\";
string dst_path = TerminalInfoString(TERMINAL_DATA_PATH)+"\\MQL4\\";
string src_file = "a.txt";
string dst_file = "b.txt";
int file_hndl;
file_hndl = FileOpen(src_path+src_file,FILE_WRITE);
FileClose(file_hndl);
ShellExecuteW (NULL, "open", "cmd", "/c copy /Y "+src_path+src_file+" "+dst_path+dst_file, NULL, NULL);

 

#import "kernel32.dll"
  bool CopyFileW(string lpExistingFileName, string lpNewFileName, bool bFailIfExists);
#import

string src_path = TerminalInfoString(TERMINAL_DATA_PATH)+"\\MQL4\\Files\\";
string dst_path = TerminalInfoString(TERMINAL_DATA_PATH)+"\\MQL4\\";
string src_file = "a.txt";
string dst_file = "b.txt";
int file_hndl;
file_hndl = FileOpen(src_path+src_file,FILE_WRITE);
FileClose(file_hndl);
CopyFileW(src_path+src_file,dst_path+dst_file,false);
 
I guess the dll will move files within mt4 terminal folder and not outside to other windows folders?
 
thank you for this fantastic help.