Access a text file from multiples programs

How can I grant that my content will not crash if multiples programs access and modify a text file, and these accesses can occur at the same time?

I know that within a program I can use
isOpen member of std::fstream class, but from multiples programs =S
You need to create a mutex to prevent concurent writing to the file. This means that every process must wait while other process write to the file.

I recommend you to just use sqlite library which does exactly this and does it very well.
It's kind of a long read but this is how Windows wants you to accomplish stuff like that: http://msdn.microsoft.com/en-us/library/ms684212(VS.85).aspx

EDIT: With file mapping views it will allow your programs to access and "modify" the file at the same time so long as it is not locked by a process, but only the most recent save will be relavent. Otherwise you need a program to mediate the changes that all of the process are making.
Last edited on
Thank you for your help.
Topic archived. No new replies allowed.