How can I make sure that my program is the only one accessing a file? Ans. By using the sopen() function, you can open a file in shared mode and explicitly deny reading and writing permissions to any other program but yours. This task is accomplished by using the SH_DENYWR shared flag to denote that your program is going to deny any writing or reading attempts by other programs. For example, the following snippet of code shows a file being opened in shared mode, denying access to all other files: /* Note that the sopen() function is not ANSI compliant... */ fileHandle = sopen('C:\\DATA\\SETUP.DAT', O_RDWR, SH_DENYWR); By issuing this statement, all other programs are denied access to the SETUP.DAT file. If another program were to try to open SETUP.DAT for reading or writing, it would receive an EACCES error code, denoting that access is denied to the file. - Study24x7
Social learning Network
13 Apr 2023 01:03 PM study24x7 study24x7

How can I make sure that my program is the only one accessing a file? Ans. By using the sopen() function, you can open a file in shared mode and explicitly deny reading and writing permissions to any other program but yours. This task is accomplished by using the SH_DENYWR share...

See more

study24x7
Write a comment
Related Questions
500+   more Questions to answer
Most Related Articles