how create file with variable name

 

hi

in filehandle we can use const string name for filename.

how we can use variable string?

i want to create a file with current local time name:

datetime tm=TimeCurrent();
string strtime=TimeToString(tm,TIME_DATE|TIME_SECONDS);
string InpFileName=strtime;
string fn="";
fn+=InpDirectoryName+"//"+InpFileName;
int file_handle=FileOpen(fn,FILE_READ|FILE_WRITE|FILE_CSV|FILE_ANSI);



Documentation on MQL5: Constants, Enumerations and Structures / Input/Output Constants / File Opening Flags
Documentation on MQL5: Constants, Enumerations and Structures / Input/Output Constants / File Opening Flags
  • www.mql5.com
File Opening Flags - Input/Output Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
sharonyazdi ghasemiani:

hi

in filehandle we can use const string name for filename.

how we can use variable string?

i want to create a file with current local time name:

   Code:

string bookname = StringFormat("%s_%s_Ticks.csv",my_symbol,TimeToString(StructToTime(startday),TIME_DATE));
 
sharonyazdi ghasemiani: how we can use variable string?

i want to create a file with current local time name:

string strtime=TimeToString(tm,TIME_DATE|TIME_SECONDS);
string InpFileName=strtime; 

Filenames can not contain slashes or colons. Create a name without them.