<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>out &#62;&#62; m_Conscientia; &#187; FileSystemWatcher</title>
	<atom:link href="http://blog.hypercomplex.co.uk/index.php/tag/filesystemwatcher/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.hypercomplex.co.uk</link>
	<description>a multidimensional braindump</description>
	<lastBuildDate>Sat, 27 Aug 2011 19:16:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>FileSystemWatcher</title>
		<link>http://blog.hypercomplex.co.uk/index.php/2009/07/filesystemwatcher/</link>
		<comments>http://blog.hypercomplex.co.uk/index.php/2009/07/filesystemwatcher/#comments</comments>
		<pubDate>Sat, 25 Jul 2009 23:14:49 +0000</pubDate>
		<dc:creator>Alex Peck</dc:creator>
				<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Application Development Foundation]]></category>
		<category><![CDATA[FileSystemWatcher]]></category>

		<guid isPermaLink="false">http://blog.hypercomplex.co.uk/?p=209</guid>
		<description><![CDATA[The FileSystemWatcher class provides a mechanism for raising events based on changes to the file system (files or directories). The Filter property allows you to specify which file(s) you are interested in watching. The NotifyFilter allows you to specify which events to watch for (created/modified/deleted etc.). You can also specify whether or not to IncludeSubdirectories. [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx">FileSystemWatcher</a> class provides a mechanism for raising events based on changes to the file system (files or directories).</p>
<p>The <a href="http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.filter.aspx">Filter</a> property allows you to specify which file(s) you are interested in watching. The <a href="http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.notifyfilter.aspx">NotifyFilter</a> allows you to specify which events to watch for (created/modified/deleted etc.). You can also specify whether or not to <a href="http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.includesubdirectories.aspx">IncludeSubdirectories</a>. Using these properties correctly ensures that a manageable amount of file system events are raised (see below).</p>
<p>FileSystemWatcher events use three delegate types:</p>
<ul>
<li>Changed, Created, Deleted events use FileSystemEventHandler</li>
<li>Renamed events use a RenamedEventHandler </li>
<li>Error events use a ErrorEventHandler</li>
</ul>
<p>You should minimise the work performed in these event handlers, otherwise you can impact the number of events you may handle.</p>
<p>There is also a synchronous WaitForChanged method which returns a structure containing changes.</p>
<p><strong>Caveats</strong></p>
<p>I would advise setting the error handler first, otherwise you can get silent failures when setting other properties.</p>
<p>Generally, it is not advisable to use FileSystemWatcher on network drives. If/when a network outage occurs the watcher ceases to function, a simple workaround is given <a href="http://www.codeguru.com/csharp/.net/net_general/eventsanddelegates/article.php/c9113">here</a>.</p>
<p>The underlying Win 32 ReadDirectoryChangesW function will fail with ERROR_INVALID_PARAMETER if the buffer length is greater than 64 KB and the application is monitoring a directory over a network. This is due to a packet size limitation with the underlying file sharing protocols.</p>
<p>Furthermore, there is no guarantee that you will recieve notification of every change under heavy load scenarios. This is compounded for network shares, since you have a smaller buffer size limitation. See <a href="http://social.msdn.microsoft.com/forums/en-US/netfxbcl/thread/4465cafb-f4ed-434f-89d8-c85ced6ffaa8/">this</a> page for a detailed explanation.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hypercomplex.co.uk/index.php/2009/07/filesystemwatcher/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

