Download MetaTrader 5
To add comments, please log in or register
Post web links to other trader's signals and make profit
Lance Wynn
26
Lance Wynn 2007.06.06 21:53 
I have been trying to use the FindFirstFile, and FindNextFile, but I cannot seem to get them to work. Does anyone have any sample code to show how to obtain a list of files in a directory?

Lance
Daniel F
363
Daniel F 2008.06.05 00:56  

yeah, that's what I am looking for, too.

Could you please tell us how to do it? Do we have to write a DLL for it?


Daniel

Rashid Umarov
Admin
6606
Rashid Umarov 2008.06.05 12:41  

See sample script:

//+------------------------------------------------------------------+
//|                                                CheckFindFile.mq4 |
//|                      Copyright © 2008, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/"
 
#property show_inputs
 
#import "kernel32.dll"
int  FindFirstFileA(string path, int& answer[]);
bool FindNextFileA(int handle, int& answer[]);
bool FindClose(int handle);
#import
//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
//----
   int LP[82];
   
   int handle = FindFirstFileA(TerminalPath() + "\experts\*.mq4",LP);
   //Print("error = ", GetLastError());
   Print(bufferToString(LP));
   ArrayInitialize(LP,0);
   while (FindNextFileA(handle,LP))
      {
      Print(bufferToString(LP));
      ArrayInitialize(LP,0);
      }
 
   if (handle>0) FindClose(handle);
   
//----
   return(0);
  }
  
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+ 
string bufferToString(int buffer[])
   {
   string text="";
   
   int pos = 11;
   for (int i=0; i<65; i++)
      {
      pos++;
      int curr = buffer[pos];
      text = text + CharToStr(curr & 0x000000FF)
         +CharToStr(curr >> 8 & 0x000000FF)
         +CharToStr(curr >> 16 & 0x000000FF)
         +CharToStr(curr >> 24 & 0x000000FF);
      }
   return (text);
   }  
//+------------------------------------------------------------------+
Daniel F
363
Daniel F 2008.06.05 14:10  

thanks so much, Rosh. Your support is amazing, we're glad to have you.

pgk
3
pgk 2012.05.05 09:43  
After hours of googleing u finally made my day. Thank u
RFB
127
RFB 2012.05.05 10:04  
You haven't probably searched why when dos had been created were (skipped 7) used every next 8-th bits ;).
och
448
och 2014.03.20 08:53  
Rosh:

See sample script:

Dear Rosh,

This code does not works anymore on build 610, any idea?

Regards,

Alain Verleyen
Moderator
28672
Alain Verleyen 2014.03.20 13:34  
och:

Dear Rosh,

This code does not works anymore on build 610, any idea?

Regards,


Strings in mql4 are know using Unicode instead of ANSI, you have to use WinApi function accordingly.
/
To add comments, please log in or register