creating a file

To add comments, please log in or register
Bruno Baekelandt
7
Bruno Baekelandt  
Just start to write my own EA and the second line give me already trouble :/

string fileName = Symbol() + "Test.txt";
int x1 = MessageBox(fileName ,"deBug",MB_OK);
int ret = FileOpen(fileName,FILE_CSV|FILE_READ,';');
if (ret < 1)
{
ret = GetLastError();
}
int x2 = MessageBox(DoubleToStr( ret, 2) ,"deBug",MB_OK);

Or GetLastError give me 4103 'Can't open file' or I never get to the second MessageBox.

Can I create a file if there is not one?
Where must/will the file be?

Thanks from a newbie
Slava
Moderator
13397
Slava  
Please read MetaEditor dictionary
==
If FILE_WRITE does not combine with FILE_READ, a zero-length file will be opened. If even the file containd some data, they will be deleted. If there is a need to add data to an existing file, it must be opened using combination of FILE_READ | FILE_WRITE.
If FILE_READ does not combine with FILE_WRITE, the file will be opened only if it already exists. If the file does not exist, it can be created using the FILE_WRITE mode.
===
To add comments, please log in or register