I am working on file locking for first time, and couldn't find relevant posts for solution in Google.
I am locking a file using this code, to lock file.
ifile = CreateFileW(FileName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_DELETE | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
In next line I am trying to open the same file using
errno_t ErrorNumber = _wfopen_s(FileHandle, FileName, "rb");
The purpose is to lock the file to prevent any other process from writing to it, while this function is reading its contents. I am getting EACCESS : 13 error code when opening the file with "rb".
Any ideas why and how to enable reading the file after locking it ?
Thanks Sujatha