Welcome to mql4.com forum,
From the documentation we can read about FILE_SHARE_READ :
Shared access for reading from several programs. Flag is used in FileOpen(), but it does not replace the necessity to indicate FILE_WRITE and/or the FILE_READ flag when opening a file.
I used the following combination of mode_flag
int filehandle=FileOpen("abc.csv",FILE_SHARE_READ|FILE_CSV)
int filehandle=FileOpen("abc.csv",FILE_READ|FILE_SHARE_READ|FILE_CSV)
int filehandle=FileOpen("abc.csv",FILE_SHARE_READ|FILE_READ)
But still facing the same problem of file being locked down.
Thank You
You open the file, but don't say what type or for which direction. | int filehandle=FileOpen("sample.csv",FILE_SHARE_READ);Try FILE_READ|FILE_SHARE_READ|FILE_CSV |
Then you seek to the end of the file. | FileSeek(filehandle,0,SEEK_END);Why are you seeking? |
You then try to read past the end of the file, which gets nothing (because you are at the END) (and even if it did, you throw that string away,) then the IF does nothing. | if(StringLen(FileReadString(fileHandle))>0){ Print("FileContent "+ FileReadString(fileHandle)); |
Perhaps you want something like: | string data = FileReadString(fileHandle); if(StringLen(data)>0){ Print("FileContent "+ data); |
You open the file, but don't say what type or for which direction. | Try FILE_READ|FILE_SHARE_READ|FILE_CSV |
Then you seek to the end of the file. | Why are you seeking? |
You then try to read past the end of the file, which gets nothing (because you are at the END) (and even if it did, you throw that string away,) then the IF does nothing. | |
Perhaps you want something like: |
The purpose of this script is to detect any change(Addition of new csv rows) in the csv file so at the start of script it move to end of file and in each timer tick script sees that if there is any new data added.
My problem is that the file is LOCKED and can not be edited by other process unless I CloseHandle or stop the script.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am writing mql script to look for any change in the file and if it detectes any change in the file then it performs some trading function
But after the mql "FileOpen "call desired file becomes unusable by other application even with "FILE_SHARE_READ" flag.
What I am doing wrong or this is how Mql FileOpen works.
Here is my script
Thank you for your help