Is there a way to enumerate the files in the Expert/files folder?

 

Hi,

as far as you know, is there any way to retrieve by code a list of the files (and how many) contained in the \files folder? 

 

Thanks

Regards

Stefano 

 
spronti:

Hi,

as far as you know, is there any way to retrieve by code a list of the files (and how many) contained in the \files folder? 

 

Thanks

Regards

Stefano 

Please read the article https://www.mql5.com/en/articles/1540. However, the article is using obsolete WinAPI function and there are several problem already discussed in the forum without solution. 
 
spronti: as far as you know, is there any way to retrieve by code a list of the files (and how many) contained in the \files folder? 
Untested
#include <WinUser32.mqh>
 bool Shell(string file, string parameters=""){
    #define DEFDIRECTORY NULL
    #define OPERATION "open"    // or print
    #define SW_SHOWNORMAL       1
    int r=ShellExecuteA(0, OPERATION, file, parameters, DEFDIRECTORY, SW_SHOWNORMAL);
    if (r <= 32){   Alert("Shell failed: ", r); return(false);  }
    return(true);
}
void forAllFiles(){
    if (isTesting())    string experts="tester";    else experts="files";
    string  filePath    = TerminalPath() + "\\"+experts+"\\files\\",
            fileRE      = "",   // Nothing or * = all files
            dirName     = WindowExpertName() + "Dir.txt",   // Dir output
            command     = "DIR /B "+filePath+fileRE+" > "+filePath+dirName;
    if (!Shell("cmd.exe", "/C "+command)) ... 
    sleep(5000);
    int handle          = FileOpen(dirName, FILE_CSV|FILE_READ, '~');
    if (handle < 1) ...
    while(true){    // Not EOF
        string line = FileReadString(handle);    if (line == "") break;

// Programmatically renaming files...any way to do it with ShellExecuteA?
// https://forum.mql4.com/40593
Untested