From: Tom on
Here is snippets of my code:

FILE_NOTIFY_INFORMATION info[8];

h = CreateFile( TEXT("C:\\abc"),
FILE_LIST_DIRECTORY, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED,
NULL);

ReadDirectoryChangesW(h, &info, sizeof(info), true,
FILE_NOTIFY_CHANGE_LAST_WRITE, &dwSize, NULL, NULL);

How come when I call ReadDirectoryChangesW and it blocks until I overwrite
an existing file, I get two records in the info structure. The 2nd one has an
action code of 116 with no file name. The 1st record contains the correct
information with NextEntryOffset equal to 0. The behavior is the same on
async calls too.

Please help.
Thanks
From: Antonius on

"Tom" <Tom(a)discussions.microsoft.com> schreef in bericht
news:A5423AA1-E7B2-4083-B2C2-D095F916C677(a)microsoft.com...
> Here is snippets of my code:
>
> FILE_NOTIFY_INFORMATION info[8];
>
> h = CreateFile( TEXT("C:\\abc"),
> FILE_LIST_DIRECTORY, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
> OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED,
> NULL);
>
> ReadDirectoryChangesW(h, &info, sizeof(info), true,
> FILE_NOTIFY_CHANGE_LAST_WRITE, &dwSize, NULL, NULL);
>
> How come when I call ReadDirectoryChangesW and it blocks until I overwrite
> an existing file, I get two records in the info structure. The 2nd one has
an
> action code of 116 with no file name. The 1st record contains the correct
> information with NextEntryOffset equal to 0. The behavior is the same on
> async calls too.
>
> Please help.
> Thanks

If the NextEntryOffset field in the first entry is zero then there is no
second entry, even if more data is available in the buffer (just treat it as
padding).

Antoon


From: Tom on
Thank you for your response, that is what I wound up doing, but how come for
everytime a new files gets saved, ReadDirectoryChangesW gets called twice for
the one file save?

Thanks,
Tom

"Antonius" wrote:

>
> "Tom" <Tom(a)discussions.microsoft.com> schreef in bericht
> news:A5423AA1-E7B2-4083-B2C2-D095F916C677(a)microsoft.com...
> > Here is snippets of my code:
> >
> > FILE_NOTIFY_INFORMATION info[8];
> >
> > h = CreateFile( TEXT("C:\\abc"),
> > FILE_LIST_DIRECTORY, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
> > OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED,
> > NULL);
> >
> > ReadDirectoryChangesW(h, &info, sizeof(info), true,
> > FILE_NOTIFY_CHANGE_LAST_WRITE, &dwSize, NULL, NULL);
> >
> > How come when I call ReadDirectoryChangesW and it blocks until I overwrite
> > an existing file, I get two records in the info structure. The 2nd one has
> an
> > action code of 116 with no file name. The 1st record contains the correct
> > information with NextEntryOffset equal to 0. The behavior is the same on
> > async calls too.
> >
> > Please help.
> > Thanks
>
> If the NextEntryOffset field in the first entry is zero then there is no
> second entry, even if more data is available in the buffer (just treat it as
> padding).
>
> Antoon
>
>
>
From: rgentile rgentile on
I am having the same problem. I don't expect this behavior to change but I'm
wondering if anyone can recommend a way to handle it?

Robert

"Tom" wrote:

> Thank you for your response, that is what I wound up doing, but how come for
> everytime a new files gets saved, ReadDirectoryChangesW gets called twice for
> the one file save?
>
> Thanks,
> Tom
>
> "Antonius" wrote:
>
> >
> > "Tom" <Tom(a)discussions.microsoft.com> schreef in bericht
> > news:A5423AA1-E7B2-4083-B2C2-D095F916C677(a)microsoft.com...
> > > Here is snippets of my code:
> > >
> > > FILE_NOTIFY_INFORMATION info[8];
> > >
> > > h = CreateFile( TEXT("C:\\abc"),
> > > FILE_LIST_DIRECTORY, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
> > > OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED,
> > > NULL);
> > >
> > > ReadDirectoryChangesW(h, &info, sizeof(info), true,
> > > FILE_NOTIFY_CHANGE_LAST_WRITE, &dwSize, NULL, NULL);
> > >
> > > How come when I call ReadDirectoryChangesW and it blocks until I overwrite
> > > an existing file, I get two records in the info structure. The 2nd one has
> > an
> > > action code of 116 with no file name. The 1st record contains the correct
> > > information with NextEntryOffset equal to 0. The behavior is the same on
> > > async calls too.
> > >
> > > Please help.
> > > Thanks
> >
> > If the NextEntryOffset field in the first entry is zero then there is no
> > second entry, even if more data is available in the buffer (just treat it as
> > padding).
> >
> > Antoon
> >
> >
> >