From 8d7622f18a1affa327d6eb0435107fa3763fcdaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Cant=C3=BA?= Date: Mon, 15 Aug 2022 16:21:06 -0500 Subject: [PATCH] Use buffer.Length as the source of truth for ReadDirectoryChanges --- .../src/System/IO/FileSystemWatcher.Win32.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.Win32.cs b/src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.Win32.cs index 96d601de841b8b..ebf8f5facb3d2f 100644 --- a/src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.Win32.cs +++ b/src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.Win32.cs @@ -158,7 +158,7 @@ private unsafe void Monitor(AsyncReadState state) continueExecuting = Interop.Kernel32.ReadDirectoryChangesW( state.DirectoryHandle, state.Buffer, // the buffer is kept pinned for the duration of the sync and async operation by the PreAllocatedOverlapped - _internalBufferSize, + (uint)state.Buffer.Length, _includeSubdirectories, (uint)_notifyFilters, null,