//+------------------------------------------------------------------+ //| Demo_FileDelete.mq5 | //| Copyright 2013, MetaQuotes Software Corp. | //| http://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2013, MetaQuotes Software Corp." #property link "http://www.mql5.com" #property version "1.00" //--- show the window of input parameters when launching the script #property script_show_inputs //--- date for old files input datetime InpFilesDate=D'2013.01.01 00:00'; //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { string file_name; // variable for storing file names string filter="*.txt"; // filter for searching the files datetime create_date; // file creation date string files[]; // list of file names int def_size=25; // array size by default int size=0; // number of files //--- allocate memory for the array ArrayResize(files,def_size); //--- receive the search handle in the local folder's root long search_handle=FileFindFirst(filter,file_name); //--- check if FileFindFirst() executed successfully if(search_handle!=INVALID_HANDLE) { //--- searching files in the loop do { files[size]=file_name; //--- increase the array size size++; if(size==def_size) { def_size+=25; ArrayResize(files,def_size); } //--- reset the error value ResetLastError(); //--- receive the file creation date create_date=(datetime)FileGetInteger(file_name,FILE_CREATE_DATE,false); //--- check if the file is old if(create_date