I am working on a C++ application that detects changes happening on a shared folder (using ReadDirectoryChangesW
) and call NetFileEnum
on that modified file/folder. This way, I know the possible candidates modifying file/folder.
According to NetFileEnum
docs:
Returns information about some or all open files on a server, depending on the parameters specified.
However, NetFileEnum is not consistent, it does not always tell me who is currently accessing the resource. It seems to work only 50-60% of the time.
More specifically, say I modify \\172.20.30.40\myshare\file.txt
(local path: C:\myshare\file.txt
).
NetFileEnum
is then called with the following parameters:
fStatus = NetFileEnum(L"\\\\172.20.30.40",
(LPWSTR)szLocalPathStr.c_str(), // C:\\myshare\\file.txt
pszUserName, // NULL
dLevel, // 3
(LPBYTE*)&pFile,
dPrefMaxLen,
&dEntriesRead,
&dTotalEntries,
NULL);
fStatus
returns NERR_success
(0). However, 40-50% of the time, dEntriesRead
is 0. Is this a known issue with NetFileEnum? Is there a more consistent way to know who all are accessing a shared resource?