Reading And Writing On The Same File
-
Hai, I am having two applications that run simultaneously. One program writes data to a file and the other program reads data from that file itself and performs some operations based on the value of that file.The problem is that since both are using same file there will be a chance to request to read the file while the file is writing.Is there any method 2 use a single file for two programs.
-
Hai, I am having two applications that run simultaneously. One program writes data to a file and the other program reads data from that file itself and performs some operations based on the value of that file.The problem is that since both are using same file there will be a chance to request to read the file while the file is writing.Is there any method 2 use a single file for two programs.
Use
CreateFile
to open the file and specify thedwShareMode
parameter asFILE_SHARE_READ|FILE_SHARE_WRITE
.«_Superman_» I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) -
Hai, I am having two applications that run simultaneously. One program writes data to a file and the other program reads data from that file itself and performs some operations based on the value of that file.The problem is that since both are using same file there will be a chance to request to read the file while the file is writing.Is there any method 2 use a single file for two programs.
In addition to what _superman_ has mentioned, you may have to use a notification methode like an event (http://msdn.microsoft.com/en-us/library/ms686915(VS.85).aspx[^]) so that the first app can notify the other app when it is ready for the read.
-
In addition to what _superman_ has mentioned, you may have to use a notification methode like an event (http://msdn.microsoft.com/en-us/library/ms686915(VS.85).aspx[^]) so that the first app can notify the other app when it is ready for the read.