The DeleteFileW function can't delete the log file

 

I use kernal32.dll function to delete the log file as just the expert is initializing but it don't working,... every other type file is deleting through this function but the required log file is not possible to delete at the time of initiaziation. I just want to clear all text inside the log at initialiation, if that possible then also that will be good

The delete I want for to clear all previous text inside file and terminal will made another file automatically,... and as I think this is not done by mt4 to allow us to delete log file when terminal is open.

If terminal is open and I want to clear the content inside this file then How I can do this?

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   DeleteFileW(TerminalInfoString(TERMINAL_DATA_PATH)+"\\MQL4\\Logs\\"+TimeToStr(TimeCurrent(),TIME_DATE)+".log");
   LastAlert = 0;
   bot.Token(myBotToken);
   getme_result = bot.GetMe();
   EventSetTimer(2);
   return(INIT_SUCCEEDED);
  }
 
Please edit your post and use the code button (Alt+S) when pasting code.
EDIT your original post, please do not just post the code correctly in a new post.
Reason: