Filedelete question?

 

what is wrong with this code. it doesnot work..

if (OrdersTotal()==0)
             FileDelete ("mydata.dat");
I am just trying to delete the file if there are no open positions.  thanks in advance..

            
 

Files can only be deleted if they are in the terminal_dir\experts\files directory (terminal_directory\tester\files, in case of testing) or its subdirectories.

 
qjol:

Files can only be deleted if they are in the terminal_dir\experts\files directory (terminal_directory\tester\files, in case of testing) or its subdirectories.


Thats where the file is. OI get the message in experts log.... cannot delete file

 
i assume you have to close the file before deleting.
 
zzuegg:
i assume you have to close the file before deleting.

sure, zzuegg is right, no question at all, most be done before deleting, an open file can't be deleted
 
qjol:

sure no question at all
Do you have FileClose(handle); before FileDelete("mydata.dat") ?
 
Hallo!
I didn't realy get what were you talking about... I'm pretty new in this stuff and still don't know all the issues, so please give an explanation :) Thanks in advance
_____________
I'm trying http://www.annaforex. com
 
robofx.org:
Do you have FileClose(handle); before FileDelete("mydata.dat") ?


the file isnt open. it is a seperate function in ea to delete the file ir open orders ==0

 
gavin:


the file isnt open. it is a seperate function in ea to delete the file ir open orders ==0


maybe you was not closing in ea after read or write something. so, for the system is still open!

For Example:

int WriteLog(string EA,string LogText)
{
int      hf;
hf=FileOpen(EA+Symbol()+"_"+Year()+"_"+Month()+"_"+Day()+".txt",FILE_CSV|FILE_READ|FILE_WRITE,";");
FileSeek(hf,0,SEEK_END);
FileWrite(hf,TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS) + ": " + LogText); 
FileClose(hf);
return(hf);
}
Reason: