How to copy file from a tester ffolder to local folder using ShellExecuteA() Function?

To add comments, please log in or register
jaffer wilson
769
jaffer wilson  

I have tried a code for copying the generated file from the tester folder to local, but I guess it is not working as I see that the return code is 2, which means file was not found.

Kindly, have a look at my code:

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

void OnDeinit(const int reason)
  {
   FileClose(file);
   Print("Shell shows:  ",ShellExecuteA(0,"copy","C:\\Users\\jaffer\\AppData\\Roaming\\MetaQuotes\\Tester\\D0E8209F77C8CF37AD8BF550E51FF075\\Agent-127.0.0.1-3000\\MQL5\\Files\\Data\\data.csv"
                 ,"C:\\Users\\jaffer\\AppData\\Roaming\\MetaQuotes\\Terminal\\D0E8209F77C8CF37AD8BF550E51FF075\\MQL5\\Files\\DataCollection\\data.csv"
                 ,"C:\\Users\\jaffer\\AppData\\Roaming\\MetaQuotes\\Terminal\\D0E8209F77C8CF37AD8BF550E51FF075\\MQL5\\Files\\DataCollection",1));
  }

Please let me know your view what I missed or what I need to do. I have even tried the path : 

C:\\Users\\jaffer\\AppData\\Roaming\\MetaQuotes\\Tester\\D0E8209F77C8CF37AD8BF550E51FF075\\Agent-127.0.0.1-3000\\MQL5\\Files\\Data\\*.*

If in case I need to copy multiple files. But nothing worked. Please guide me.

Quoc Thinh
15
Quoc Thinh  
jaffer wilson :

I have try a code to copy the files created from the test directory to local method, but it guess it is not active as it see the payment code is 2, means that is not found.

Please see the code of me:

Xin vui lòng cho tôi biết quan điểm của bạn những gì tôi đã bỏ lỡ hoặc những gì tôi cần làm. Tôi thậm chí đã thử đường dẫn: 

If in the case you must copy more files. But no effect. Please please instruction for me.

Anton Nel
49586
Anton Nel  

Create new scripts and then test from there...Tested and it worked.

#import "shell32.dll" 
int ShellExecuteW(int hwnd,string operation,string file,string parameters,string directory,int showCmd); 
#import

#define SW_SHOWNORMAL       1

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
{
   string strFrom = "C:\\Temp\\Test01\\*.*";
   string strTo = "C:\\Temp\\Test02\\";

   string strParameters = "/c copy " + strFrom + " " + strTo;
   
   int result = ShellExecuteW(0, "open", "cmd.exe", strParameters, NULL, SW_SHOWNORMAL);
   if (result <= 32) Alert("Shell Execute Failed: ", result); 
}
//+------------------------------------------------------------------+
jaffer wilson
769
jaffer wilson  
Anton Nel :

Create new scripts and then test from there...Tested and it worked.

Hey Anton, is there a way I can appreciate your answer? As there is a score system on many forum or something like a clap or +1 or thumbs up.. I do not see this on the forum. I would love to appreciate your answer. It works.

To add comments, please log in or register