How are FILE_SHARE_READ&WRITE working exactly?

 

Hi,

i have some problems working with files and am on the search for help. Please, will anyone explain how to use FILE_SHARE_READ&WRITE correctly?

   string subfolder="Trade";
   filehandle=FileOpen(subfolder+"\\Active.csv",FILE_COMMON|FILE_SHARE_WRITE|FILE_SHARE_READ|FILE_CSV,',');
   if(filehandle==INVALID_HANDLE){
         Print(__FUNCTION__,space,"File open failed, error ",GetLastError());
         return(false);}
   for (int i=0;i<loops;i++)
   {
            // Write data to file
             FileWrite(filehandle,TimeToString(TimeCurrent(),TIME_DATE|TIME_MINUTES),.... and so on i write here set of values may be 10 or so);
   }
   FileFlush(filehandle);
   FileClose(filehandle);

But what i get is nothing written to the file. When I change to FILE_READ|FILE_WRITE it is working. What am I missing to do here?

I need share reading/writing because the file is used simultaneously from other MT5s. Also is there a limitation of how many MT5s can have access to a file at ones?

There was no topic on this issue on the forum so answers will be highly appreciated!

Thank You

Documentation on MQL5: Standard Constants, Enumerations and Structures / Input/Output Constants / File Opening Flags
  • www.mql5.com
Standard Constants, Enumerations and Structures / Input/Output Constants / File Opening Flags - Documentation on MQL5
 

Don't forget FILE_READ or FILE_WRITE flag!

FILE_SHARE... flags needed for access sharing only 

Documentation on MQL5: Standard Constants, Enumerations and Structures / Input/Output Constants / File Opening Flags
  • www.mql5.com
Standard Constants, Enumerations and Structures / Input/Output Constants / File Opening Flags - Documentation on MQL5
 

Oh, thanks! I had assumed that one includes the other. Thank you stringo!