Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
System.IO Namespace
 InternalBufferSize Property
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
FileSystemWatcher..::.InternalBufferSize Property

Gets or sets the size of the internal buffer.

Namespace:  System.IO
Assembly:  System (in System.dll)
Visual Basic (Declaration)
<BrowsableAttribute(False)> _
Public Property InternalBufferSize As Integer
Visual Basic (Usage)
Dim instance As FileSystemWatcher
Dim value As Integer

value = instance.InternalBufferSize

instance.InternalBufferSize = value
C#
[BrowsableAttribute(false)]
public int InternalBufferSize { get; set; }
Visual C++
[BrowsableAttribute(false)]
public:
property int InternalBufferSize {
    int get ();
    void set (int value);
}
JScript
public function get InternalBufferSize () : int
public function set InternalBufferSize (value : int)

Property Value

Type: System..::.Int32
The internal buffer size. The default is 8192 (8 KB).

The buffer can be set to anything above 4096 (4 KB), but for best performance, it should be a multiple of 4 KB on Intel-based computers.

NoteNote:

The maximum buffer size that can be set for monitoring a directory over the network is 64 KB.

The system notifies the component of file changes, and it stores those changes in a buffer the component creates and passes to the APIs. Each event can use up to 16 bytes of memory, not including the file name. If there are many changes in a short time, the buffer can overflow. This causes the component to lose track of changes in the directory, and it will only provide blanket notification. Increasing the size of the buffer has the following ramifications:

  • Increasing the buffer size can prevent missing file system change events. Note that an instance of the FileSystemWatcher class does not raise an Error event when an event is missed or when the buffer size is exceeded, due to dependencies with the Windows operating system.

  • Increasing buffer size is expensive, as it comes from non paged memory that cannot be swapped out to disk, so keep the buffer as small as possible. To avoid a buffer overflow, use the NotifyFilter and IncludeSubdirectories properties to filter out unwanted change notifications.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
FileSystemWatcher doesn't fire events for monitored network drive after changing InternalBufferSize      Kim Hamilton - MSFT   |   Edit   |   Show History
If you notice that FileSystemWatcher doesn't fire events for monitored network drive after changing InternalBufferSize, a common problem is that the value provided to InternalBufferSize is invalid, but you only get notification of the problem if you add an error handler via FileSystemWatcher.Error. Make sure to add an error handler to get notification of this and other failures. See more details here:
http://blogs.msdn.com/kimhamil/archive/2008/04/27/filesystemwatcher-doesn-t-fire-events-for-monitored-network-drive-after-changing-internalbuffersize.aspx

Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker