- Don't install in \program files* on Vista/Win7
Installation of MetaTrader 4 can not be in \ program files *?. It is best to install in another directory?.
It can be in Program Files . . . but then you need to be aware of the implications and impact of UAC. If you install in another directory, e.g. C:\MT4_Installs\ you will not have any UAC issues.
Hi jugivi
I would beg to differ on the answers you have been given. I was getting the same problem while trying to delete 2 files that may or may not have existed when I initialized an indicator.
I was able to finally fix the problem by closing the file before trying to delete it. Now it all works perfectly without any errors appearing no matter what the file existence conditions are,
and yes, this on a wiindows 7 machine installed under the program files directory with UAC active.
Hope this helps
Regards
Lyndon
Here is my code...
//---- Declare UI settable, file logging related variables.
extern bool LogResults = true; // Set to true to write on screen comments to a log file for offline processing.
extern bool DeleteResultsLog = true; // Set to true to delete summary file each time indicator is initialised.
extern bool LogTrades = true; // Set to true to write all trades to a log file for offline processing.
extern bool DeleteTradesLog = true; // Set to true to delete trades log file each time indicator is initialised.
//---- Declare & define filename used to log results. Located in c:\Program Files\{broker name or MT4 or MetaTrader 4}\experts\files
string SummaryFile = "summary log.csv";
string TradesFile = "trade data log.csv";
int init()
{
//--- Prepare strategy log file names.
SummaryFile = StringConcatenate(IndiName," ",SummaryFile); // add indi name to log file name
TradesFile = StringConcatenate(IndiName," ",TradesFile); // add indi name to log file name
if (DeleteResultsLog)
{
LogFileHandle = FileOpen(SummaryFile,FILE_CSV|FILE_READ);
if (LogFileHandle >=0) {FileClose(LogFileHandle); FileDelete(SummaryFile);} // if summary log file exists, delete it.
}
if (DeleteTradesLog)
{
LogFileHandle = FileOpen(TradesFile,FILE_CSV|FILE_READ);
if (LogFileHandle >=0) {FileClose(LogFileHandle); FileDelete(TradesFile);} // if trades data log file exists, delete it.
}
hi,
i have a problem with FileDelete(). My delete-fuction is:
bool DeleteFileCSV(string s_fileName, bool b_debugMode = false) { if (CheckForFileExistCSV(s_fileName, b_debugMode)) { FileDelete(s_fileName); int i_error = GetLastError(); if (i_error == ERR_NO_ERROR) { if (b_debugMode && true) { Print("DeleteFile(): return=true; i_error=", DoubleToStr(i_error, 0), "; ErrorDescription(", DoubleToStr(i_error, 0), ")=", ErrorDescription(i_error), "; s_fileName=", s_fileName); } return (true); } else { if (b_debugMode && true) { Print("DeleteFile(): return=false; i_error=", DoubleToStr(i_error, 0), "; ErrorDescription(", DoubleToStr(i_error, 0), ")=", ErrorDescription(i_error), "; s_fileName=", s_fileName); } return (false); } } }
the delete is running without problems on empty files and on datafilled .csv-files but...
if i read some data from the file before deleting i got the error 4099 (end of file)
and in spite of that error the file is deleted ???
My read-function:
bool GetValuesOfLastLine(int i_handle, bool b_debugMode = false) { if (FileSize(i_handle) != 0 && true) { int i = 0; string s_newLineDelimiter = ""; while(s_newLineDelimiter != "@") { FileSeek(i_handle, i, SEEK_END); s_newLineDelimiter = FileReadString(i_handle); i--; } // gt_date = StrToTime(FileReadString(i_handle)); // gd_deposits = StrToDouble(FileReadString(i_handle)); // gd_profitTarget = StrToDouble(FileReadString(i_handle)); // gd_balanceTarget = StrToDouble(FileReadString(i_handle)); } return (true); }
Why is there that 4099-error but the file is deleted ???
Thanks...
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Can anyone help me?, When trying to delete a file I get the error 4100 (Some File Error). Below you can see the code I use. Thank you.
int handle_input;
string file_name="operaciones_file.csv";
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
handle_input=FileOpen(file_name,FILE_CSV|FILE_READ,',');
if(handle_input < 1)
{
if(GetLastError()==4099)
Alert("Fin de archivo... ",file_name);
if(GetLastError()==4103)
Alert("No existe el fichero... ",file_name);
if(GetLastError()==4100)
Alert("Some file error ",file_name);
if(GetLastError()==4101)
Alert("Wrong file name ",file_name);
if(GetLastError()==4104)
Alert("Incompatible access to a file ",file_name);
else
Alert("Error while opening file ",file_name);
return;
}
//
FileClose(handle_input);
//
int lastError;
FileDelete("operaciones_file.csv");
lastError = GetLastError();
if (lastError != 0)
{
Alert("An error ocurred while (",lastError,") deleting file");
return(0);
}
return(0);
}