Unable to Find CSV File

 

Hello,

Unable to find file test1.csv on my Windows 7 laptop after executing the following function using MetaEditor Build 409. I'm executing this as a script. the mq4 file is in folder Scripts. Experts tab and Alert window shows file test1.csv was opened and closed successfully, no errors. I'm expecting to find file test1.csv in folder experts\files or tester\files. A search for *.csv in my OANDA - MetaTrader folder comes up empty. Why? Thanks and Regards, Doug

int test1()
{
int iHandle;
int iErrorCode;
int iInteger=1;
int iDecimalPlaces=5;
string sString="string";
string sFileName = "test1.csv";
double dDouble=1.123456789;

iHandle = FileOpen(sFileName,FILE_CSV|FILE_WRITE,';');
if(iHandle < 1)
{
iErrorCode = GetLastError();
Alert("Error Opening File: ",iErrorCode);
Print("Error Opening File: ",iErrorCode);
return(0);
}
else
{
Alert("File "+sFileName+" opened.");
Print("File "+sFileName+" opened.");
}
FileWrite(iHandle, "Integer","String","Double");
FileWrite(iHandle,iInteger,sString,DoubleToStr(dDouble,iDecimalPlaces));
FileFlush(iHandle);
FileClose(iHandle);
Alert("File "+sFileName+" closed. "+TimeToStr(TimeCurrent(), TIME_SECONDS));
return(0);
}

 

It's probably a UAC issue . . . do a search under UAC and you will find some solutions . . . also

Please use this to post code . . . it makes it easier to read.

 
RaptorUK:

It's probably a UAC issue . . . do a search under UAC and you will find some solutions . . . also

Please use this to post code . . . it makes it easier to read.


Thanks RaptorUK!

I used "Run As Administrator" when I launched MetaTrader and MetaEditor. Problem solved. I'll have to carefully handle files since the apps are running with extended priviledges. Next time I'll post source with the SRC button. Best Regards, Doug

 
livingfully:


Thanks RaptorUK!

I used "Run As Administrator" when I launched MetaTrader and MetaEditor. Problem solved. I'll have to carefully handle files since the apps are running with extended priviledges. Next time I'll post source with the SRC button. Best Regards, Doug

You don't need to run as admin. Just install it into a folder where user has write permissions. Make a folder c:\mt4\ and install it there. Dont install it in "program files". The MT4 installer is wrong in suggesting the program files folder, MT4 is actually designed like a portable app, it is keeping its data inside the program folder and this is not allowed in Windows.
 
7bit:
You don't need to run as admin. Just install it into a folder where user has write permissions. Make a folder c:\mt4\ and install it there. Dont install it in "program files". The MT4 installer is wrong in suggesting the program files folder, MT4 is actually designed like a portable app, it is keeping its data inside the program folder and this is not allowed in Windows.

Excellent explantion 7bit! I now have a better understanding of what's happening. Thanks and Best Regards, Doug
Reason: