<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feedburner.timvw.be/~d/styles/itemcontent.css"?><rss 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/" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Tim Van Wassenhove</title>
	
	<link>http://www.timvw.be</link>
	<description>The journey of a thousand miles begins with one step.</description>
	<lastBuildDate>Sat, 27 Apr 2013 16:38:29 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feedburner.timvw.be/timvw" /><feedburner:info uri="timvw" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><creativeCommons:license>http://creativecommons.org/licenses/by-sa/2.0/</creativeCommons:license><item>
		<title>The curious case of trailing spaces in SQL</title>
		<link>http://feedburner.timvw.be/~r/timvw/~3/voXdeTu6nfQ/</link>
		<comments>http://www.timvw.be/2013/04/27/the-curious-case-of-trailing-spaces-in-sql/#comments</comments>
		<pubDate>Sat, 27 Apr 2013 16:38:29 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[t-sql]]></category>

		<guid isPermaLink="false">http://www.timvw.be/?p=2330</guid>
		<description><![CDATA[A while ago I was quite surprised to see that the following query returns 1 instead of 0: SELECT COUNT(*) WHERE N'Tim' = N'Tim '; -- notice the trailing space Apparently this is just standard behaviour. Here is an extract &#8230;<p class="read-more"><a href="http://www.timvw.be/2013/04/27/the-curious-case-of-trailing-spaces-in-sql/">Read more &#187;</a></p>]]></description>
				<content:encoded><![CDATA[<p>A while ago I was quite surprised to see that the following query returns 1 instead of 0:</p>
<p><code lang="sql"><br />
SELECT COUNT(*) WHERE N'Tim' = N'Tim '; -- notice the trailing space<br />
</code></p>
<p>Apparently this is just standard behaviour. Here is an extract from <a href="http://www.andrew.cmu.edu/user/shadow/sql/sql1992.txt">sql1992.txt</a> (Section 8.2 Paragraph 3):</p>
<p><quote>
<pre>
     3) The comparison of two character strings is determined as fol-
            lows:

            a) If the length in characters of X is not equal to the length
              in characters of Y, then the shorter string is effectively
              replaced, for the purposes of comparison, with a copy of
              itself that has been extended to the length of the longer
              string by concatenation on the right of one or more pad char-
              acters, where the pad character is chosen based on CS. If
              CS has the NO PAD attribute, then the pad character is an
              implementation-dependent character different from any char-
              acter in the character set of X and Y that collates less
              than any string under CS. Otherwise, the pad character is a
              <space>.

            b) The result of the comparison of X and Y is given by the col-
              lating sequence CS.

            c) Depending on the collating sequence, two strings may com-
              pare as equal even if they are of different lengths or con-
              tain different sequences of characters. When the operations
              MAX, MIN, DISTINCT, references to a grouping column, and the
              UNION, EXCEPT, and INTERSECT operators refer to character
              strings, the specific value selected by these operations from
              a set of such equal values is implementation-dependent.
</pre>
<p></quote></p>
<img src="http://feeds.feedburner.com/~r/timvw/~4/voXdeTu6nfQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/2013/04/27/the-curious-case-of-trailing-spaces-in-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.timvw.be/2013/04/27/the-curious-case-of-trailing-spaces-in-sql/</feedburner:origLink></item>
		<item>
		<title>Sample query to demonstrate influence of collation in Sql Server</title>
		<link>http://feedburner.timvw.be/~r/timvw/~3/DrIE8cpYI5A/</link>
		<comments>http://www.timvw.be/2012/10/18/sample-query-to-demonstrate-influence-of-collation-in-sql-server/#comments</comments>
		<pubDate>Thu, 18 Oct 2012 08:22:25 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[collation]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.timvw.be/?p=2301</guid>
		<description><![CDATA[Lately I had the pleasure to investigate collations and here is a sample query that demonstrates how a collation impacts the behaviour of a query:]]></description>
				<content:encoded><![CDATA[<p>Lately I had the pleasure to investigate <a href="http://technet.microsoft.com/en-us/library/aa174903(v=sql.80).aspx">collations</a> and here is a sample query that demonstrates how a collation impacts the behaviour of a query:</p>
<pre class="brush: sql; title: ; notranslate">
WITH [Words] AS (
	SELECT N'Een' AS [word]
	UNION ALL
	SELECT N'Eèn'
	UNION ALL
	SELECT N'EEN'
)
	SELECT [word]
	FROM [Words]
	WHERE [word] 
		--COLLATE Latin1_General_CS_AS -- returns Een
		--COLLATE Latin1_General_CI_AI -- returns Een, Eèn and EEN
		--COLLATE LAtin1_General_CI_AS -- returns Een and EEN
		COLLATE Latin1_General_CS_AI -- returns Een and Eèn
		= N'Een';
</pre>
<img src="http://feeds.feedburner.com/~r/timvw/~4/DrIE8cpYI5A" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/2012/10/18/sample-query-to-demonstrate-influence-of-collation-in-sql-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.timvw.be/2012/10/18/sample-query-to-demonstrate-influence-of-collation-in-sql-server/</feedburner:origLink></item>
		<item>
		<title>Copy all mp3 files in Music folder to USB dribe</title>
		<link>http://feedburner.timvw.be/~r/timvw/~3/mS_FxfqDFTc/</link>
		<comments>http://www.timvw.be/2012/09/22/copy-all-mp3-files-in-music-folder-to-usb-dribe/#comments</comments>
		<pubDate>Sat, 22 Sep 2012 21:08:46 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[mac]]></category>

		<guid isPermaLink="false">http://www.timvw.be/?p=2294</guid>
		<description><![CDATA[Copying all mp3 files from my Music folder to a USB drive is pretty easy on my Macbook:]]></description>
				<content:encoded><![CDATA[<p>Copying all mp3 files from my Music folder to a USB drive is pretty easy on my Macbook:</p>
<pre class="brush: bash; title: ; notranslate">
find Music -name *.mp3 -exec cp {} /Volumes/SANDISK \;
</pre>
<img src="http://feeds.feedburner.com/~r/timvw/~4/mS_FxfqDFTc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/2012/09/22/copy-all-mp3-files-in-music-folder-to-usb-dribe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.timvw.be/2012/09/22/copy-all-mp3-files-in-music-folder-to-usb-dribe/</feedburner:origLink></item>
		<item>
		<title>Using eID on OS X Mountain Lion</title>
		<link>http://feedburner.timvw.be/~r/timvw/~3/H40cBIMD6qQ/</link>
		<comments>http://www.timvw.be/2012/08/06/using-eid-on-os-x-mountain-lion/#comments</comments>
		<pubDate>Mon, 06 Aug 2012 21:45:52 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.timvw.be/?p=2280</guid>
		<description><![CDATA[Last week or so I got myself a MacBook Air and I am really loving it so far. Today I needed to use my eID so I installed the middleware application without any hassle but had a hard time configuring &#8230;<p class="read-more"><a href="http://www.timvw.be/2012/08/06/using-eid-on-os-x-mountain-lion/">Read more &#187;</a></p>]]></description>
				<content:encoded><![CDATA[<p>Last week or so I got myself a MacBook Air and I am really loving it so far. Today I needed to use my <a href="http://eid.belgium.be/en/">eID</a> so I installed the middleware application without any hassle but had a hard time configuring Safari. Apparently Apply removed support for <a href="http://en.wikipedia.org/wiki/PKCS_?11">PKCS #11</a> in <a href="http://www.apple.com/osx/">OS X Mountain Lion</a>. After installing <a href="http://smartcardservices.macosforge.org">SmartCard Services</a> the certificates appeared in the Keychain and I became able to authenticate on websites using my certificate</p>
<img src="http://feeds.feedburner.com/~r/timvw/~4/H40cBIMD6qQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/2012/08/06/using-eid-on-os-x-mountain-lion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.timvw.be/2012/08/06/using-eid-on-os-x-mountain-lion/</feedburner:origLink></item>
		<item>
		<title>Add missing books to iTunes</title>
		<link>http://feedburner.timvw.be/~r/timvw/~3/L50q-G9PxMM/</link>
		<comments>http://www.timvw.be/2012/05/20/add-missing-books-to-itunes/#comments</comments>
		<pubDate>Sun, 20 May 2012 18:57:34 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[iTunes]]></category>

		<guid isPermaLink="false">http://www.timvw.be/?p=2271</guid>
		<description><![CDATA[These days i read most books on my ipad. The problem is that iTunes does not seem to add pdf files when i choose &#8216;Add Folder&#8217; to the library. So here is a small application that adds them one by &#8230;<p class="read-more"><a href="http://www.timvw.be/2012/05/20/add-missing-books-to-itunes/">Read more &#187;</a></p>]]></description>
				<content:encoded><![CDATA[<p>These days i read most books on my ipad. The problem is that iTunes does not seem to add pdf files when i choose &#8216;Add Folder&#8217; to the library. So here is a small application that adds them one by one (way too lazy/unmotivated to do this by hand).</p>
<p><a href="https://gist.github.com/2759128">https://gist.github.com/2759128</a></p>
<img src="http://feeds.feedburner.com/~r/timvw/~4/L50q-G9PxMM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/2012/05/20/add-missing-books-to-itunes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.timvw.be/2012/05/20/add-missing-books-to-itunes/</feedburner:origLink></item>
		<item>
		<title>Multiclean solution</title>
		<link>http://feedburner.timvw.be/~r/timvw/~3/EatNGqr_nz8/</link>
		<comments>http://www.timvw.be/2012/04/26/multiclean-solution/#comments</comments>
		<pubDate>Thu, 26 Apr 2012 14:08:07 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://www.timvw.be/?p=2267</guid>
		<description><![CDATA[One of my favorite powershell commands when cleaning up:]]></description>
				<content:encoded><![CDATA[<p>One of my favorite powershell commands when cleaning up:</p>
<pre class="brush: powershell; title: ; notranslate">
$RootFolder = 'C:\tfs'
Get-ChildItem $RootFolder bin -Recurse | Remove-Item -Recurse
Get-ChildItem $RootFolder obj -Recurse | Remove-Item -Recurse
</pre>
<img src="http://feeds.feedburner.com/~r/timvw/~4/EatNGqr_nz8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/2012/04/26/multiclean-solution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.timvw.be/2012/04/26/multiclean-solution/</feedburner:origLink></item>
		<item>
		<title>An example of Common Table Expression and Window function usage…</title>
		<link>http://feedburner.timvw.be/~r/timvw/~3/nbFVueaH_Wg/</link>
		<comments>http://www.timvw.be/2012/03/27/an-example-of-common-table-expression-and-window-function-usage/#comments</comments>
		<pubDate>Tue, 27 Mar 2012 09:33:37 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[t-sql]]></category>

		<guid isPermaLink="false">http://www.timvw.be/?p=2260</guid>
		<description><![CDATA[Earlier this week some colleague had been assigned a maintenance task and asked me how I would solve it. Every customer is permitted to have an amount of publications. All excess publications should be removed from the system (only the &#8230;<p class="read-more"><a href="http://www.timvw.be/2012/03/27/an-example-of-common-table-expression-and-window-function-usage/">Read more &#187;</a></p>]]></description>
				<content:encoded><![CDATA[<p>Earlier this week some colleague had been assigned a maintenance task and asked me how I would solve it. Every customer is permitted to have an amount of publications. All excess publications should be removed from the system (only the n most recent ones are permitted to remain on the system).</p>
<p>Here is an example of the Customer table:</p>
<pre class="brush: sql; title: ; notranslate">
CREATE TABLE [dbo].[Customer](
	[CustomerId] [int] IDENTITY(1,1) NOT NULL,
	[CustomerName] [nvarchar](50) NOT NULL,
	[PermittedPublications] [int] NOT NULL
);

INSERT INTO [dbo].[Customer] 
			([CustomerName], [PermittedPublications]) 
VALUES	
			('timvw', 2),
			('mike', 3);
</pre>
<p>An example of the customer publications table:</p>
<pre class="brush: sql; title: ; notranslate">
CREATE TABLE [dbo].[Publication](
	[PublicationId] [int] IDENTITY(1,1) NOT NULL,
	[CustomerId] [int] NOT NULL,
	[PublicationName] [nvarchar](50) NOT NULL,
	[PublicationTime] [datetime2] NOT NULL
);
                         
INSERT INTO [dbo].[Publication] 
			([CustomerId], [PublicationName],[PublicationTime])
VALUES      
			((SELECT [CustomerId] FROM [dbo].[Customer] WHERE [CustomerName] = 'timvw'), 'tim pub1', SYSUTCDATETIME()),
			((SELECT [CustomerId] FROM [dbo].[Customer] WHERE [CustomerName] = 'timvw'), 'tim pub2', SYSUTCDATETIME()),
			((SELECT [CustomerId] FROM [dbo].[Customer] WHERE [CustomerName] = 'timvw'), 'tim pub3', SYSUTCDATETIME()),
			((SELECT [CustomerId] FROM [dbo].[Customer] WHERE [CustomerName] = 'timvw'), 'tim pub4', SYSUTCDATETIME()),
			((SELECT [CustomerId] FROM [dbo].[Customer] WHERE [CustomerName] = 'mike'), 'mike pub1', SYSUTCDATETIME()),
			((SELECT [CustomerId] FROM [dbo].[Customer] WHERE [CustomerName] = 'mike'), 'mike pub2', SYSUTCDATETIME());
</pre>
<p>My colleague was keen on using some cursor logic, but I demonstrated him how a set-based alternative:</p>
<pre class="brush: sql; title: ; notranslate">		
WITH [RankedPublication] AS (
	SELECT [CustomerId]
	      ,[PublicationId]
	      ,[PublicationName]
	      ,[PublicationTime]
	      ,ROW_NUMBER() OVER(PARTITION BY [CustomerId] ORDER BY [PublicationTime]) AS [PublicationRank]
	FROM [dbo].[Publication]
), [ExcessPublication] AS (
	SELECT [PublicationId]
	FROM [RankedPublication]
	INNER JOIN [dbo].[Customer] ON [Customer].[CustomerId] = [RankedPublication].[CustomerId]
	WHERE [PublicationRank] &gt; [Customer].[PermittedPublications]
)
	DELETE FROM [dbo].[Publication]
	WHERE [PublicationId] IN (SELECT [PublicationId] FROM [ExcessPublication]);
</pre>
<img src="http://feeds.feedburner.com/~r/timvw/~4/nbFVueaH_Wg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/2012/03/27/an-example-of-common-table-expression-and-window-function-usage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.timvw.be/2012/03/27/an-example-of-common-table-expression-and-window-function-usage/</feedburner:origLink></item>
		<item>
		<title>Say no to primitives in your API.. and make your software more explicit</title>
		<link>http://feedburner.timvw.be/~r/timvw/~3/aXDSUdBPVGw/</link>
		<comments>http://www.timvw.be/2011/10/28/say-no-to-primitives-in-your-api-and-make-your-software-more-explicit/#comments</comments>
		<pubDate>Fri, 28 Oct 2011 09:51:52 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.timvw.be/?p=2245</guid>
		<description><![CDATA[A while ago I wrote some code like this: A bit later the requirements changed and from now on it was required to specify the topic: In case you were using Broadcast(string message) the compiler would rightfully inform you that &#8230;<p class="read-more"><a href="http://www.timvw.be/2011/10/28/say-no-to-primitives-in-your-api-and-make-your-software-more-explicit/">Read more &#187;</a></p>]]></description>
				<content:encoded><![CDATA[<p>A while ago I wrote some code like this:</p>
<pre class="brush: csharp; title: ; notranslate">
public interface ICanBroadcast
{
 public void Broadcast(string message) { ... }
 public void Broadcast(string message, string author) { ... }
}
</pre>
<p>A bit later the requirements changed and from now on it was required to specify the topic:</p>
<pre class="brush: csharp; title: ; notranslate">
public interface ICanBroadcast
{
 public void Broadcast(string message, string topic) { ... }
 public void Broadcast(string message, string author, string topic) { ... }
}
</pre>
<p>In case you were using Broadcast(string message) the compiler would rightfully inform you that no such method exists. In case you were using Broadcast(string message, string author) the compiler does not catch the error and incorrectly uses the author as topic. I can only hope that you have a suite of tests that makes you notice that something is wrong when you upgrade to my latest release.
<p/>
<p>Let&#8217;s make the difference between an Author and a Topic more explicit (to our API consumers and the compiler) by creating explicit types to represent the concepts:</p>
<pre class="brush: csharp; title: ; notranslate">
public interface ICanBroadcast
{
 public void Broadcast(Message message, Topic topic) { ... }
 public void Broadcast(Message message, Author author, Topic topic) { ... }
}
</pre>
<p>The joy of using a typed language <img src='http://www.timvw.be/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<img src="http://feeds.feedburner.com/~r/timvw/~4/aXDSUdBPVGw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/2011/10/28/say-no-to-primitives-in-your-api-and-make-your-software-more-explicit/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.timvw.be/2011/10/28/say-no-to-primitives-in-your-api-and-make-your-software-more-explicit/</feedburner:origLink></item>
		<item>
		<title>Force the removal of a file with PowerShell</title>
		<link>http://feedburner.timvw.be/~r/timvw/~3/EDOOE9vIU74/</link>
		<comments>http://www.timvw.be/2011/10/18/force-the-removal-of-a-file-with-powershell/#comments</comments>
		<pubDate>Tue, 18 Oct 2011 18:44:08 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://www.timvw.be/?p=2240</guid>
		<description><![CDATA[Last couple of weeks I have been generating a lot of files (and restricting their ACLs) and today I decided to remove all those files. The problem is that my user account did not have permissions on those files. Here &#8230;<p class="read-more"><a href="http://www.timvw.be/2011/10/18/force-the-removal-of-a-file-with-powershell/">Read more &#187;</a></p>]]></description>
				<content:encoded><![CDATA[<p>Last couple of weeks I have been generating a lot of files (and restricting their ACLs) and today I decided to remove all those files. The problem is that my user account did not have permissions on those files. Here is a small script that will first take ownership of the file, then grants FullControl permissions, and finally removes the file <img src='http://www.timvw.be/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<pre class="brush: powershell; title: ; notranslate">
function RemoveFile
{
	param($FileName)
	
	&amp;takeown /F $FileName
	
	$User = [System.Security.Principal.WindowsIdentity]::GetCurrent().User
	
	$Acl = Get-Acl $FileName
	$Acl.SetOwner($User)
	$AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule($User, &quot;FullControl&quot;, &quot;Allow&quot;)
	$Acl.SetAccessRule($AccessRule)
	Set-Acl $FileName $Acl

	Remove-Item $FileName
}

Get-ChildItem *.txt -R | % { RemoveFile $_.FullName; }
</pre>
<p><b>Edit on 2011-10-19</b></p>
<p>Resetting the permissions with icacls c:\output /reset /t and then calling Remove-Item c:\output -R does the trick.</p>
<pre class="brush: powershell; title: ; notranslate">
function RemoveFiles
{
 param($Directory)
 icacls $Directory /reset /t
 Remove-Item $Directory -R
}

RemoveFiles c:\output;
</pre>
<img src="http://feeds.feedburner.com/~r/timvw/~4/EDOOE9vIU74" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/2011/10/18/force-the-removal-of-a-file-with-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.timvw.be/2011/10/18/force-the-removal-of-a-file-with-powershell/</feedburner:origLink></item>
		<item>
		<title>Remove all access rules from a directory</title>
		<link>http://feedburner.timvw.be/~r/timvw/~3/mSjGaDf-Gi0/</link>
		<comments>http://www.timvw.be/2011/09/22/remove-all-access-rules-from-a-directory/#comments</comments>
		<pubDate>Thu, 22 Sep 2011 17:56:04 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://www.timvw.be/?p=2226</guid>
		<description><![CDATA[A while ago i needed to write some code that removes all (existing/inherited) access rules from a given directory. It was pretty frustrating to notice that all my attempts seemed to fail (RemoveAccessRule, PurgeAccessRule, &#8230;) Finally i found that SetAccessRuleProtection &#8230;<p class="read-more"><a href="http://www.timvw.be/2011/09/22/remove-all-access-rules-from-a-directory/">Read more &#187;</a></p>]]></description>
				<content:encoded><![CDATA[<p>A while ago i needed to write some code that removes all (existing/inherited) access rules from a given directory. It was pretty frustrating to notice that all my attempts seemed to fail (<a href="http://msdn.microsoft.com/en-us/library/system.security.accesscontrol.commonobjectsecurity.removeaccessrule.aspx">RemoveAccessRule</a>, <a href="http://msdn.microsoft.com/en-us/library/system.security.accesscontrol.objectsecurity.purgeaccessrules.aspx">PurgeAccessRule</a>, &#8230;)</p>
<p>Finally i found that <a href="">SetAccessRuleProtection</a> was the method that i needed to invoke.</p>
<pre class="brush: csharp; title: ; notranslate">
const string Folder = @&quot;c:\temp\secured&quot;;
var directory = new DirectoryInfo(Folder);
var directorySecurity = directory.GetAccessControl();
directorySecurity.SetAccessRuleProtection(true,false);
directory.SetAccessControl(directorySecurity);
</pre>
<div id="attachment_2235" class="wp-caption alignnone" style="width: 387px"><a href="http://www.timvw.be/wp-content/uploads/2011/09/directorysecurity.png"><img src="http://www.timvw.be/wp-content/uploads/2011/09/directorysecurity.png" alt="Image of the security properties tab in windows" title="directorysecurity" width="377" height="461" class="size-full wp-image-2235" /></a><p class="wp-caption-text">Image of the security properties tab in windows</p></div>
<p>There you go <img src='http://www.timvw.be/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<img src="http://feeds.feedburner.com/~r/timvw/~4/mSjGaDf-Gi0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/2011/09/22/remove-all-access-rules-from-a-directory/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.timvw.be/2011/09/22/remove-all-access-rules-from-a-directory/</feedburner:origLink></item>
	</channel>
</rss>
