<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>c#</title>
        <link>http://blog.crowe.co.nz/category/11.aspx</link>
        <description>c#</description>
        <language>en-NZ</language>
        <copyright>Chris Crowe</copyright>
        <managingEditor>blog@crowe.co.nz</managingEditor>
        <generator>Subtext Version 1.9.4.0</generator>
        <item>
            <title>Code Camp in Christchurch, New Zealand in November 2007</title>
            <link>http://blog.crowe.co.nz/archive/2007/08/25/Code-Camp-in-Christchurch-New-Zealand-in-November-2007.aspx</link>
            <description>&lt;p&gt;&lt;img height="201" alt="" width="205" align="right" src="/images/blog_crowe_co_nz/CodeCamp.gif" /&gt;I see that there is now offical talk of a Code Camp in Christchurch, New Zealand in November 2007 which is good to see. I hope for some confirmed dates soon.&lt;/p&gt;
&lt;p&gt;This is great news as the Mainland as we call it (the South Island of New Zealand) has never had a Code Camp before.&lt;/p&gt;
&lt;p&gt;For pre-registrations &lt;font face="Arial"&gt;and more details see &lt;font face="Arial"&gt;&lt;a href="http://dot.net.nz/Default.aspx?tabid=108"&gt;http://dot.net.nz/Default.aspx?tabid=108&lt;/a&gt; &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;The theme of the code camp is Next generation, back to basics.  &lt;/p&gt;
&lt;p&gt;New releases of C#, VB, .Net, ASP and SQL are iminent.  This code camp will focus on getting up to speed with all of this, plus cover migration stratigies and many non-technology specific topics such as Architecture and Development Life Cycle.  Hopefully something for everyone - noobs, gurus, youg and old.&lt;/p&gt;
&lt;p&gt;I have been asked to speak on IIS 7 and will be providing a session on this somewhere over the two day event. &lt;/p&gt;
&lt;p&gt;I also spoke to &lt;a href="http://www.dan.net.nz/"&gt;Daniel Wissa &lt;/a&gt;( at TechEd 2007) who runs the Christchurch .NET user group with &lt;a href="http://www.jonesie.net.nz/"&gt;Peter Jones [MVP]&lt;/a&gt; about running a shared session some time this year on Windows Vista Gadget Development. The code camp may be a good time for this session as well.&lt;/p&gt;
&lt;p&gt; I am trying to get some sponser support as well - but I will keep it quiet until I know the result.&lt;/p&gt;&lt;img src="http://blog.crowe.co.nz/aggbug/764.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Chris Crowe</dc:creator>
            <guid>http://blog.crowe.co.nz/archive/2007/08/25/Code-Camp-in-Christchurch-New-Zealand-in-November-2007.aspx</guid>
            <pubDate>Sat, 25 Aug 2007 07:28:33 GMT</pubDate>
            <comments>http://blog.crowe.co.nz/archive/2007/08/25/Code-Camp-in-Christchurch-New-Zealand-in-November-2007.aspx#feedback</comments>
            <wfw:commentRss>http://blog.crowe.co.nz/comments/commentRss/764.aspx</wfw:commentRss>
        </item>
        <item>
            <title>c# - An example of setting NTFS Directory / File ACLS</title>
            <link>http://blog.crowe.co.nz/archive/2007/08/25/c---An-example-of-setting-NTFS-Directory--File.aspx</link>
            <description>&lt;p&gt;Below is a simple c# console application that shows how you can set the NTFS ACLs for a directory. &lt;/p&gt;
&lt;p&gt;You are probably aware of the DirectoryInfo object which you can use to get details on a folder, but there is also the ability to get and set the NTFS file ACLs (Access Control List Entries)&lt;/p&gt;
&lt;p&gt;No special reference need to be made in order to use the code.&lt;/p&gt;
&lt;pre&gt;&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.IO; 
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Security.AccessControl; 

&lt;span style="COLOR: blue"&gt;namespace&lt;/span&gt; DirectoryPermissions 
{ 
    &lt;span style="COLOR: blue"&gt;internal&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; Program 
    { 
        &lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; Main(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;[] args) 
        { 
            &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; ADDomain = &lt;span style="COLOR: maroon"&gt;"Domain"&lt;/span&gt;; 
            &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; ADUser = &lt;span style="COLOR: maroon"&gt;"Chris"&lt;/span&gt;; 
            &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; Path = &lt;span style="COLOR: maroon"&gt;@"c:\temp\chris"&lt;/span&gt;; 

            &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (Directory.Exists(Path) == &lt;span style="COLOR: maroon"&gt;false&lt;/span&gt;) 
                Directory.CreateDirectory(Path); 

            &lt;span style="COLOR: green"&gt;// Remove any inheritable permissions from the path&lt;/span&gt; 
            RemoveInheritablePermissons(Path); 

            &lt;span style="COLOR: green"&gt;// Add the access control entries for the path&lt;/span&gt; 
            AddDirectorySecurity(Path, ADDomain + &lt;span style="COLOR: maroon"&gt;"\\"&lt;/span&gt; + ADUser, FileSystemRights.Modify, 
                                 InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, 
                                 PropagationFlags.None, AccessControlType.Allow); 
            AddDirectorySecurity(Path, ADDomain + &lt;span style="COLOR: maroon"&gt;"\\Domain Users"&lt;/span&gt;, FileSystemRights.Delete, InheritanceFlags.None, 
                                 PropagationFlags.None, AccessControlType.Deny); 
            AddDirectorySecurity(Path, ADDomain + &lt;span style="COLOR: maroon"&gt;"\\Domain Admins"&lt;/span&gt;, FileSystemRights.FullControl, 
                                 InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, 
                                 PropagationFlags.None, AccessControlType.Allow); 
        } 


        &lt;span style="COLOR: green"&gt;// Adds an ACL entry on the specified directory for the specified account.&lt;/span&gt; 
        &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; AddDirectorySecurity(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; FileName, &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; Account, FileSystemRights Rights, 
                                                InheritanceFlags Inheritance, PropagationFlags Propogation, 
                                                AccessControlType ControlType) 
        { 
            &lt;span style="COLOR: green"&gt;// Create a new DirectoryInfo object.&lt;/span&gt; 
            DirectoryInfo dInfo = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; DirectoryInfo(FileName); 
            &lt;span style="COLOR: green"&gt;// Get a DirectorySecurity object that represents the &lt;/span&gt; 
            &lt;span style="COLOR: green"&gt;// current security settings.&lt;/span&gt; 
            DirectorySecurity dSecurity = dInfo.GetAccessControl(); 
            &lt;span style="COLOR: green"&gt;// Add the FileSystemAccessRule to the security settings. &lt;/span&gt; 
            dSecurity.AddAccessRule(&lt;span style="COLOR: blue"&gt;new&lt;/span&gt; FileSystemAccessRule(Account, 
                                                             Rights, 
                                                             Inheritance, 
                                                             Propogation, 
                                                             ControlType)); 
            &lt;span style="COLOR: green"&gt;// Set the new access settings.&lt;/span&gt; 
            dInfo.SetAccessControl(dSecurity); 
        } 

        &lt;span style="COLOR: green"&gt;// Removes an ACL entry on the specified directory for the specified account.&lt;/span&gt; 
        &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; RemoveDirectorySecurity(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; FileName, &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; Account, FileSystemRights Rights, 
                                                   AccessControlType ControlType) 
        { 
            &lt;span style="COLOR: green"&gt;// Create a new DirectoryInfo object.&lt;/span&gt; 
            DirectoryInfo dInfo = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; DirectoryInfo(FileName); 
            &lt;span style="COLOR: green"&gt;// Get a DirectorySecurity object that represents the &lt;/span&gt; 
            &lt;span style="COLOR: green"&gt;// current security settings.&lt;/span&gt; 
            DirectorySecurity dSecurity = dInfo.GetAccessControl(); 
            &lt;span style="COLOR: green"&gt;// Add the FileSystemAccessRule to the security settings. &lt;/span&gt; 
            dSecurity.RemoveAccessRule(&lt;span style="COLOR: blue"&gt;new&lt;/span&gt; FileSystemAccessRule(Account, 
                                                                Rights, 
                                                                ControlType)); 
            &lt;span style="COLOR: green"&gt;// Set the new access settings.&lt;/span&gt; 
            dInfo.SetAccessControl(dSecurity); 
        } 

        &lt;span style="COLOR: green"&gt;// Removes an ACL entry on the specified directory for the specified account.&lt;/span&gt; 
        &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; RemoveInheritablePermissons(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; FileName) 
        { 
            &lt;span style="COLOR: green"&gt;// Create a new DirectoryInfo object.&lt;/span&gt; 
            DirectoryInfo dInfo = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; DirectoryInfo(FileName); 
            &lt;span style="COLOR: green"&gt;// Get a DirectorySecurity object that represents the &lt;/span&gt; 
            &lt;span style="COLOR: green"&gt;// current security settings.&lt;/span&gt; 
            DirectorySecurity dSecurity = dInfo.GetAccessControl(); 
            &lt;span style="COLOR: green"&gt;// Add the FileSystemAccessRule to the security settings.&lt;/span&gt; 
            &lt;span style="COLOR: blue"&gt;const&lt;/span&gt; &lt;span style="COLOR: blue"&gt;bool&lt;/span&gt; IsProtected = &lt;span style="COLOR: maroon"&gt;true&lt;/span&gt;; 
            &lt;span style="COLOR: blue"&gt;const&lt;/span&gt; &lt;span style="COLOR: blue"&gt;bool&lt;/span&gt; PreserveInheritance = &lt;span style="COLOR: maroon"&gt;false&lt;/span&gt;; 
            dSecurity.SetAccessRuleProtection(IsProtected, PreserveInheritance); 
            &lt;span style="COLOR: green"&gt;// Set the new access settings.&lt;/span&gt; 
            dInfo.SetAccessControl(dSecurity); 
        } 
    } 
}&lt;/pre&gt;&lt;img src="http://blog.crowe.co.nz/aggbug/761.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Chris Crowe</dc:creator>
            <guid>http://blog.crowe.co.nz/archive/2007/08/25/c---An-example-of-setting-NTFS-Directory--File.aspx</guid>
            <pubDate>Fri, 24 Aug 2007 21:52:49 GMT</pubDate>
            <comments>http://blog.crowe.co.nz/archive/2007/08/25/c---An-example-of-setting-NTFS-Directory--File.aspx#feedback</comments>
            <slash:comments>8</slash:comments>
            <wfw:commentRss>http://blog.crowe.co.nz/comments/commentRss/761.aspx</wfw:commentRss>
        </item>
        <item>
            <title>c# - How to create a comma seperated string from a list of items</title>
            <link>http://blog.crowe.co.nz/archive/2007/08/25/c---How-to-create-a-comma-seperated-string-from.aspx</link>
            <description>&lt;p&gt;I found an interesting post from a work colleague "Simeon Pilgrim" at &lt;font face="Arial"&gt;&lt;a href="http://simeonpilgrim.com/blog/2007/08/23/how-to-rewriter-systemconfigurationcommadelimitedstringcollection-wrong/"&gt;http://simeonpilgrim.com/blog/2007/08/23/how-to-rewriter-systemconfigurationcommadelimitedstringcollection-wrong/&lt;/a&gt; that shows that in the System.Configuration namespace there is a very simple class that will create a comma seperated string for you.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;The class is called &lt;strong&gt;CommaDelimitedStringCollection&lt;/strong&gt; and you must add a reference to &lt;strong&gt;System.Configuration&lt;/strong&gt; in order to use it.&lt;/p&gt;
&lt;pre&gt; &lt;/pre&gt;
&lt;pre&gt;&lt;span style="COLOR: blue"&gt;&lt;/span&gt;There is a simple example of how to use it.&lt;/pre&gt;
&lt;pre&gt;&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System; 
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Collections; 
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Configuration; 

&lt;span style="COLOR: blue"&gt;namespace&lt;/span&gt; Commas 
{ 
    &lt;span style="COLOR: blue"&gt;internal&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; Program 
    { 
        &lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; Main(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;[] args) 
        { 
            ArrayList Items = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; ArrayList(); 
            Items.Add(&lt;span style="COLOR: maroon"&gt;"http://blog.crowe.co.nz"&lt;/span&gt;); 
            Items.Add("&lt;span style="COLOR: maroon"&gt;&lt;a href="http://www.simeonpilgrim.com"&gt;http://www.simeonpilgrim.com&lt;/a&gt;"&lt;/span&gt;); 
            Items.Add(&lt;span style="COLOR: maroon"&gt;"http://www.iis.net"&lt;/span&gt;); 

            CommaDelimitedStringCollection commaStr = 
                &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; CommaDelimitedStringCollection(); 

            &lt;span style="COLOR: blue"&gt;foreach&lt;/span&gt; (&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; item &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; Items) 
                commaStr.Add(item); 

            Console.WriteLine(commaStr.ToString()); 
        } 
    } 
}&lt;/pre&gt;
&lt;pre&gt;The output from the above would be :&lt;/pre&gt;
&lt;pre&gt;&lt;font size="2"&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;&lt;a href="http://blog.crowe.co.nz,http://www.simeonpilgrim.com,http://www.iis.net"&gt;http://blog.crowe.co.nz,http://www.simeonpilgrim.com,http://www.iis.net&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&lt;/font&gt;&lt;/pre&gt;
&lt;pre&gt;In the sample above we loop through each item in my ArrayList and add it to the list of strings to comma seperate.&lt;/pre&gt;
&lt;pre&gt;We could have replaced for foreach loop with this to make it a bit easier.&lt;/pre&gt;
&lt;pre&gt;&lt;font size="2"&gt;&lt;p&gt;commaStr.AddRange((&lt;font color="#0000ff" size="2"&gt;string&lt;/font&gt;&lt;font size="2"&gt;[]) Items.ToArray(&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;typeof&lt;/font&gt;&lt;font size="2"&gt;(&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;string&lt;/font&gt;&lt;font size="2"&gt;)));&lt;/font&gt;&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font size="2"&gt;I wonder how many other usefull classes are out there but no one uses them and reinvents the wheel.&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;&lt;/pre&gt;&lt;img src="http://blog.crowe.co.nz/aggbug/759.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Chris Crowe</dc:creator>
            <guid>http://blog.crowe.co.nz/archive/2007/08/25/c---How-to-create-a-comma-seperated-string-from.aspx</guid>
            <pubDate>Fri, 24 Aug 2007 21:26:55 GMT</pubDate>
            <comments>http://blog.crowe.co.nz/archive/2007/08/25/c---How-to-create-a-comma-seperated-string-from.aspx#feedback</comments>
            <slash:comments>4</slash:comments>
            <wfw:commentRss>http://blog.crowe.co.nz/comments/commentRss/759.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Looking for a way to get WinForms Developer License with Subscription and Source (value $999) for free!</title>
            <link>http://blog.crowe.co.nz/archive/2007/04/19/732.aspx</link>
            <description>&lt;div&gt;
&lt;div&gt;Telerik ( &lt;a href="http://www.telerik.com"&gt;www.telerik.com&lt;/a&gt; ) makers of some great controls for Asp.net and WinForms have a content running now that will allow you the chance to win a 50" Plasma Television.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;/div&gt;
&lt;div align="center"&gt;&lt;img id="_x0000_i1025" height="128" alt="Telerik WinForms Contest - Part II" width="183" align="right" src="http://www.telerik.com/images/newsletters/common/200704/nlWinformsChallenge2.jpg" /&gt;&lt;/div&gt;
&lt;div&gt;In order to participate you need to download &lt;strong&gt;RadControls for WinForms&lt;/strong&gt;, explore the software for a while and then answer 10 easy questions.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;font color="#ff0000"&gt;&lt;strong&gt;For 5 or more correct answers, you will receive a complimentary RadControls for WinForms Developer License with Subscription and Source (value $999).&lt;/strong&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;  &lt;/font&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;&lt;strong&gt;&lt;font style="BACKGROUND-COLOR: #ffff99" color="#ff0000"&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;a target="_blank" href="http://www.ixfr.com/?id=femihg&amp;amp;C=gej&amp;amp;R=ingnlll_mnn&amp;amp;E=fmlf&amp;amp;P=ijk&amp;amp;J=ffgfk&amp;amp;L=1"&gt;&lt;span&gt;Enter the contest now&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;  &lt;/div&gt;
&lt;div&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;&lt;strong&gt;THE AWARDS:&lt;/strong&gt;&lt;/div&gt;
&lt;strong&gt;&lt;/strong&gt;
&lt;ul&gt;
    &lt;li&gt;Grand prize: 50 inch plasma TV &lt;/li&gt;
    &lt;li&gt;The first 50 participants that answer all questions correctly will receive a $20 Amazon gift coupon. &lt;/li&gt;
&lt;/ul&gt;
&lt;!-- #7 single item end --&gt;&lt;!-- #8 single item start --&gt;&lt;img src="http://blog.crowe.co.nz/aggbug/732.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Chris Crowe</dc:creator>
            <guid>http://blog.crowe.co.nz/archive/2007/04/19/732.aspx</guid>
            <pubDate>Wed, 18 Apr 2007 22:33:09 GMT</pubDate>
            <comments>http://blog.crowe.co.nz/archive/2007/04/19/732.aspx#feedback</comments>
            <wfw:commentRss>http://blog.crowe.co.nz/comments/commentRss/732.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Telerik Code Converter - convert C# to VB.NET and visa versa</title>
            <link>http://blog.crowe.co.nz/archive/2007/04/19/731.aspx</link>
            <description>&lt;font size="2"&gt;
&lt;p&gt;Code Converter is a free and simple VB to C# and C# to VB code converter. While there are several other good code converters available, none are perfect. Some are buried in busy websites. Some are awkward to use. Some just don't convert accurately! Code Converter, while not yet perfect, aims to address these issues and provide the best free .NET converter available on the web.&lt;/p&gt;
&lt;p&gt;&lt;img height="542" width="443" alt="" src="/images/blog_crowe_co_nz/CodeConvertor.gif" /&gt;&lt;/p&gt;
&lt;p&gt;Part of the mission of delivering the best code conversion service means that it needs to be available wherever and whenever you need it. For that reason, we will be building code conversion widgets for all of the major widget engines (such as Google Desktop, Windows Sidebar, and Yahoo! Widgets) so that you can easily convert your code snippet while minimizing the interruption to your work. The following code conversion widgets are already ready and available here: &lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;&lt;a href="http://widgets.yahoo.com/gallery/view.php?widget=41587"&gt;Yahoo! Widgets Code Converter&lt;/a&gt; &lt;/li&gt;
    &lt;li&gt;&lt;a href="http://www.google.com/ig/directory?hl=en&amp;amp;root=%2Fig&amp;amp;dpos=top&amp;amp;num=24&amp;amp;url=http://www.codechanger.com/google/CodeConverterGadget.xml"&gt;Google Gadget Code Converter &lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="http://gallery.live.com/LiveItemDetail.aspx?li=75cffe62-c8d0-4feb-a028-5ac8638b5321"&gt;Windows Vista Sidebar Gadget Code Converter&lt;/a&gt; &lt;/li&gt;
    &lt;li&gt;Google Desktop Gadget Code Converter (&lt;strong&gt;coming soon&lt;/strong&gt;) &lt;/li&gt;
    &lt;li&gt;Visual Studio 2005 Add-in (&lt;strong&gt;being researched&lt;/strong&gt;) &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img height="191" width="812" alt="" src="/images/blog_crowe_co_nz/CodeConvertor1.gif" /&gt;&lt;/p&gt;
&lt;p&gt;To try on line see &lt;font face="Arial"&gt;&lt;a href="http://converter.telerik.com/Default.aspx"&gt;http://converter.telerik.com/Default.aspx&lt;/a&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Conversions by NRefactory&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;For the heavy lifting, we rely on the open source NRefactory library to perform code conversions. NRefactory is a powerful C# to VB and VB to C# conversion engine maintained by the developers at SharpDevelop. By default, NRefactory requires that all code be properly wrapped in a class and (as necessary) method before converting. We try to save you time by automagically wrapping your code snippets in "dummy wrappers" so it can be processed by NRefactory. If you're having trouble converting your code, try wrapping it in a class yourself to skip our "magic" wrapping process. &lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;&lt;font face="Arial"&gt;&lt;a href="http://www.google.com/search?q=NRefactory&amp;amp;rls=com.microsoft:*&amp;amp;ie=UTF-8&amp;amp;oe=UTF-8&amp;amp;startIndex=&amp;amp;startPage=1"&gt;http://www.google.com/search?q=NRefactory&amp;amp;rls=com.microsoft:*&amp;amp;ie=UTF-8&amp;amp;oe=UTF-8&amp;amp;startIndex=&amp;amp;startPage=1&lt;/a&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;/font&gt;&lt;img src="http://blog.crowe.co.nz/aggbug/731.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Chris Crowe</dc:creator>
            <guid>http://blog.crowe.co.nz/archive/2007/04/19/731.aspx</guid>
            <pubDate>Wed, 18 Apr 2007 21:12:37 GMT</pubDate>
            <comments>http://blog.crowe.co.nz/archive/2007/04/19/731.aspx#feedback</comments>
            <slash:comments>19</slash:comments>
            <wfw:commentRss>http://blog.crowe.co.nz/comments/commentRss/731.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Refactor!™ for ASP.NET free download from www.devexpress.com</title>
            <link>http://blog.crowe.co.nz/archive/2007/04/13/710.aspx</link>
            <description>&lt;P&gt;&lt;SPAN&gt;For those that do not know Developer Express make some really great tools and controls for .NET. They have made their Refactor tool for ASP.NET available for free.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Refactor! is freely available to all ASP.NET 2.0 developers and offers a comprehensive suite of tools that enable you and your team to simplify and shape complex code and HTML markup - making your web applications easier to read and less costly to maintain.&lt;/SPAN&gt; 
&lt;P&gt;Below is a simple example where you can refactor the source file the .APSX file into a code behind file.
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;IMG src="/images/refactor.gif"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;/SPAN&gt;If you want to watch a small 12 minute video about it see this:&lt;BR&gt;&lt;A href="http://www.devexpress.com/Products/NET/IDETools/RefactorASP/Presentation/Refactor_for_ASP_NET/"&gt;http://www.devexpress.com/Products/NET/IDETools/RefactorASP/Presentation/Refactor_for_ASP_NET/&lt;/A&gt;&lt;/SPAN&gt;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You can download it from:&lt;BR&gt;&lt;A href="http://www.devexpress.com/Products/NET/IDETools/RefactorASP/"&gt;http://www.devexpress.com/Products/NET/IDETools/RefactorASP/&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;They also have two other free Refactor products:&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;SPAN&gt;Refactor for Visual Basic&lt;/SPAN&gt; 
&lt;LI&gt;&lt;SPAN&gt;Refactor for C++&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;img src="http://blog.crowe.co.nz/aggbug/710.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Chris Crowe</dc:creator>
            <guid>http://blog.crowe.co.nz/archive/2007/04/13/710.aspx</guid>
            <pubDate>Thu, 12 Apr 2007 15:01:00 GMT</pubDate>
            <comments>http://blog.crowe.co.nz/archive/2007/04/13/710.aspx#feedback</comments>
            <slash:comments>4</slash:comments>
            <wfw:commentRss>http://blog.crowe.co.nz/comments/commentRss/710.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Free download: "Visual Studio 2005: A Guided Tour" </title>
            <link>http://blog.crowe.co.nz/archive/2007/03/13/689.aspx</link>
            <description>&lt;P&gt;&lt;IMG src="/images/msdnmag.gif" align=right&gt;This 92-page issue contains the best MSDN Magazine Visual Studio 2005 coverage from the past two years, updated for the final release. Find out what's new in C#, C++, Visual Basic, Windows Forms, ASP.NET, Team System, security, and C++generic types -- &lt;A href="http://www.sdmediagroup.com/msdnmag/specialedition.pdf"&gt;download your copy&lt;/A&gt; now!&lt;/P&gt;&lt;img src="http://blog.crowe.co.nz/aggbug/689.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Chris Crowe</dc:creator>
            <guid>http://blog.crowe.co.nz/archive/2007/03/13/689.aspx</guid>
            <pubDate>Mon, 12 Mar 2007 13:08:00 GMT</pubDate>
            <comments>http://blog.crowe.co.nz/archive/2007/03/13/689.aspx#feedback</comments>
            <slash:comments>29</slash:comments>
            <wfw:commentRss>http://blog.crowe.co.nz/comments/commentRss/689.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Retrieving the COM class factory for component with CLSID {3FA7DEB3-6438-101B-ACC1-00AA00423326} failed due to the following error: 80010106.</title>
            <link>http://blog.crowe.co.nz/archive/2006/08/15/675.aspx</link>
            <description>While trying to upgrade a .NET application from VS.NET 2003 to VS.NET 2005 I found I was getting a problem with creating a MAPI.Session object. 
&lt;P&gt;I was getting the following exception:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="/images/ExceptionSTAThread.gif" border=0&gt;&lt;/P&gt;
&lt;P&gt;Searching around in &lt;A href="http://www.google.co.nz/"&gt;www.google.co.nz&lt;/A&gt; and everywhere else I was finding nothing on this error.&lt;/P&gt;
&lt;P&gt;I decided that I would simply create a new application and see if it failed.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;I opened VS.NET 2003 
&lt;LI&gt;I created a new console application 
&lt;LI&gt;I added a reference to "Microsoft CDO 1.21 Library" 
&lt;LI&gt;I added one line of code &lt;FONT size=2&gt;MAPI.&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Session&lt;/FONT&gt;&lt;FONT size=2&gt; sess = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; MAPI.&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Session&lt;/FONT&gt;&lt;FONT size=2&gt;(); &lt;/FONT&gt;to my Main() routine&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;I then run the code and it worked fine.&lt;/P&gt;
&lt;P&gt;So I repeated the code in VS.NET 2005&lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;using&lt;/FONT&gt;&lt;FONT size=2&gt; System;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;using&lt;/FONT&gt;&lt;FONT size=2&gt; System.Collections.Generic;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;using&lt;/FONT&gt;&lt;FONT size=2&gt; System.Text;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;namespace&lt;/FONT&gt;&lt;FONT size=2&gt; ConsoleApplication1&lt;BR&gt;{&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp; class&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Program&lt;BR&gt;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT size=2&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;static&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;void&lt;/FONT&gt;&lt;FONT size=2&gt; Main(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt;[] args)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MAPI.&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Session&lt;/FONT&gt;&lt;FONT size=2&gt; sess = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; MAPI.&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Session&lt;/FONT&gt;&lt;FONT size=2&gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I was still getting the exception. I decided to post to the New Zealand .NET User group list that I belong to - see &lt;A href="http://www.dot.net.nz/"&gt;www.dot.net.nz&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I got the following response from &lt;B&gt;Alex James &lt;/B&gt;&lt;/P&gt;
&lt;P&gt;"&lt;EM&gt; I don&amp;#8217;t know the answer, but one thing I would check is whether different thread types have an effect. I.e. is you app [MTAThread] or [STAThread]&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;&lt;EM&gt;You never know that might be the answer, the default between 2003/2005 maybe different?&lt;/EM&gt; " 
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I had a look at the code that VS.NET 2003 produced and indeed it has the following attribute above the Main() procedure&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;STAThread&lt;/FONT&gt;&lt;FONT size=2&gt;]&lt;/FONT&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;using&lt;FONT size=2&gt; System;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;using&lt;/FONT&gt;&lt;FONT size=2&gt; System.Collections.Generic;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;using&lt;/FONT&gt;&lt;FONT size=2&gt; System.Text;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;namespace&lt;/FONT&gt;&lt;FONT size=2&gt; ConsoleApplication1&lt;BR&gt;{&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp; class&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Program&lt;BR&gt;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT size=2&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;FONT color=#008080 size=2&gt;STAThread&lt;/FONT&gt;&lt;FONT size=2&gt;]&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;static&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;void&lt;/FONT&gt;&lt;FONT size=2&gt; Main(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt;[] args)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MAPI.&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Session&lt;/FONT&gt;&lt;FONT size=2&gt; sess = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; MAPI.&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Session&lt;/FONT&gt;&lt;FONT size=2&gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I added the attribute to my code and the problem was gone. So obviously the CDO 1.21 library is compiled for STAThreading and not the VS.NET 2005 default which must be MTAThread.&lt;/P&gt;
&lt;P&gt;The following is from &lt;A href="http://www.sellsbrothers.com/askthewonk/Secure/WhatdoestheSTAThreadattri.htm"&gt;http://www.sellsbrothers.com/askthewonk/Secure/WhatdoestheSTAThreadattri.htm&lt;/A&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;I&gt;The STAThreadAttribute marks a thread to use the Single-Threaded COM Apartment if COM is needed. By default, .NET won't initialize COM at all. It's only when COM is needed, like when a COM object or COM Control is created or when drag 'n' drop is needed, that COM is initialized. When that happens, .NET calls the underlying CoInitializeEx function, which takes a flag indicating whether to join the thread to a multi-threaded or single-threaded apartment.&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;&lt;I&gt;A multi-threaded apartment (MTA) in COM is more efficient, since any of a number of RPC threads from a pool can be used to handle a request. However, an object on the MTA thread needs to protect itself from multiple threads accessing it at the same time, so that efficiency comes at a cost.&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;&lt;I&gt;The single-thread apartment (STA) in COM is inherently single-threaded and therefore no additional thread synchronization is needed. The STA is implemented using the thread's Windows message queue, which is how requests to objects on an STA are serialized. Because of how the STA thread is implemented, calls to objects on that thread are serialized with Windows message handling on that thread, making sure that everything, both the COM objects and the underlying windowing objects, e.g. HWNDs, are all synchronized. This is necessary for UI-oriented COM objects, like controls and drag 'n' drop, which must also be synchronized together with the UI.&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;&lt;I&gt;When COM is needed .NET will call CoInitializeEx, picking the MTA by default because it's more efficient. However, to get the synchronization needed for controls, windows and drag 'n' drop, you need to mark a thread's entry point with the STAThreadAttribute to let .NET know to initialize the UI thread on the STA. All of the VS.NET project templates put that attribute in to make sure you don't forget:&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;img src="http://blog.crowe.co.nz/aggbug/675.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Chris Crowe</dc:creator>
            <guid>http://blog.crowe.co.nz/archive/2006/08/15/675.aspx</guid>
            <pubDate>Mon, 14 Aug 2006 15:58:00 GMT</pubDate>
            <comments>http://blog.crowe.co.nz/archive/2006/08/15/675.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://blog.crowe.co.nz/comments/commentRss/675.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Some examples of scripting of IIS using ADSI, WMI from VB and C# including the new Microsoft.Web.Administration namespace</title>
            <link>http://blog.crowe.co.nz/archive/2006/07/04/663.aspx</link>
            <description>&lt;P&gt;Below are some simple examples of how to talk to IIS via ADSI, WMI and the new IIS 7 only .NET Managed Provider. &lt;/P&gt;
&lt;P&gt;&lt;B&gt;The IIS ADSI Provider&lt;/B&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;The IIS ADSI provider exposes COM Automation objects that you can use within command-line scripts, ASP pages, or custom applications to change IIS configuration values stored in the IIS metabase. IIS ADSI objects can be accessed and manipulated by any language that supports automation, such as Microsoft&amp;#174; Visual Basic&amp;#174; Scripting Edition (VBScript), Microsoft JScript&amp;#174;, Perl, Microsoft Active Server Pages (ASP), Visual Basic, Java, or Microsoft C++.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;B&gt;The IIS WMI Provider&lt;/B&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Windows Management Instrumentation (WMI) is a technology that allows administrators to programmatically manage and configure the Windows operating system and Windows applications. Beginning with IIS 6.0, IIS includes a WMI provider that exposes programming interfaces that can be used to query and configure the IIS metabase.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;B&gt;The Microsoft.Web.Administration namespace in IIS 7&lt;/B&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;This is a new .NET managed namespace that will allow you to talk to IIS 7 and configure all aspects of the server. This API is designed to be simple to code against in an &amp;#8220;intellisense-driven&amp;#8221; sort of way. At the root level a class called ServerManager exposes all the functionality you will need. At this time it appears that this will not be able to be used from Windows XP but by the time Vista &amp;amp; Windows Server are released this may have been ported to run on a Windows XP client.&lt;BR&gt;&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;For more details on these technologies see the following resources:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;B&gt;Active Directory Service Interfaces Overview&lt;/B&gt;&lt;BR&gt;&lt;A href="http://www.microsoft.com/windows2000/techinfo/howitworks/activedirectory/adsilinks.asp"&gt;http://www.microsoft.com/windows2000/techinfo/howitworks/activedirectory/adsilinks.asp&lt;/A&gt;&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;&lt;B&gt;WMI - Windows Management Instrumentation&lt;BR&gt;&lt;/B&gt;&lt;A href="http://www.microsoft.com/whdc/system/pnppwr/wmi/default.mspx"&gt;http://www.microsoft.com/whdc/system/pnppwr/wmi/default.mspx&lt;/A&gt;&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;&lt;B&gt;Administering IIS Programmatically (IIS 6.0)&lt;/B&gt;&lt;BR&gt;&lt;A href="http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/9041b0a5-c314-46d9-8f56-01506687f357.mspx"&gt;http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/9041b0a5-c314-46d9-8f56-01506687f357.mspx&lt;/A&gt;&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;&lt;B&gt;Pre-release documentation on Microsoft.Web.Administration&lt;/B&gt;&lt;BR&gt;&lt;A href="http://windowssdk.msdn.microsoft.com/en-us/library/microsoft.web.administration.aspx"&gt;http://windowssdk.msdn.microsoft.com/en-us/library/microsoft.web.administration.aspx&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;HR&gt;

&lt;H2&gt;C# -Using System.DirectoryServices and ADSI&lt;/H2&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System;
&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System.Collections.Generic;
&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System.Text;
&lt;SPAN style="COLOR: green"&gt;// Must be specified and a reference added to System.DirectoryServices&lt;/SPAN&gt;
&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System.DirectoryServices;

&lt;SPAN style="COLOR: blue"&gt;namespace&lt;/SPAN&gt; Console_EnumSites_ADSI_CSharp
{
    &lt;SPAN style="COLOR: blue"&gt;class&lt;/SPAN&gt; Program
    {
        &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; Main(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt;[] args)
        {
            DirectoryEntry entry = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; DirectoryEntry(&lt;SPAN style="COLOR: maroon"&gt;"IIS://LocalHost/W3SVC"&lt;/SPAN&gt;);
            &lt;SPAN style="COLOR: blue"&gt;foreach&lt;/SPAN&gt; (DirectoryEntry site &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; entry.Children)
            {
                &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (site.SchemaClassName == &lt;SPAN style="COLOR: maroon"&gt;"IIsWebServer"&lt;/SPAN&gt;)
                {
                    &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; ServerComment = site.Properties[&lt;SPAN style="COLOR: maroon"&gt;"ServerComment"&lt;/SPAN&gt;].Value.ToString();
                    Console.WriteLine(ServerComment + &lt;SPAN style="COLOR: maroon"&gt;" ("&lt;/SPAN&gt; + site.Name + &lt;SPAN style="COLOR: maroon"&gt;")"&lt;/SPAN&gt;);
                }
            }
        }
    }
}
&lt;/PRE&gt;
&lt;HR&gt;

&lt;H2&gt;VB -Using ADSI&lt;/H2&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: blue"&gt;on&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;error&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;resume&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;next&lt;/SPAN&gt;

&lt;SPAN style="COLOR: blue"&gt;dim&lt;/SPAN&gt; websrv, site
&lt;SPAN style="COLOR: blue"&gt;dim&lt;/SPAN&gt; webinfo

&lt;SPAN style="COLOR: blue"&gt;set&lt;/SPAN&gt; websrv = getobject(&lt;SPAN style="COLOR: maroon"&gt;"IIS://Localhost/W3SVC"&lt;/SPAN&gt;)
&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (err &amp;lt;&amp;gt; &lt;SPAN style="COLOR: maroon"&gt;0&lt;/SPAN&gt;) &lt;SPAN style="COLOR: blue"&gt;then&lt;/SPAN&gt;
&lt;SPAN style="COLOR: blue"&gt;else&lt;/SPAN&gt;
    err.Clear
    &lt;SPAN style="COLOR: blue"&gt;for&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;each&lt;/SPAN&gt; site &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; websrv
        &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (site.classname = &lt;SPAN style="COLOR: maroon"&gt;"IIsWebServer"&lt;/SPAN&gt;) &lt;SPAN style="COLOR: blue"&gt;then&lt;/SPAN&gt;
            WScript.echo Site.ServerComment &amp;amp; &lt;SPAN style="COLOR: maroon"&gt;" ("&lt;/SPAN&gt; &amp;amp; Site.Name &amp;amp; &lt;SPAN style="COLOR: maroon"&gt;")"&lt;/SPAN&gt;
        &lt;SPAN style="COLOR: blue"&gt;end&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;
    &lt;SPAN style="COLOR: blue"&gt;next&lt;/SPAN&gt;
&lt;SPAN style="COLOR: blue"&gt;end&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;HR&gt;

&lt;H2&gt;C# -Using System.Managment and WMI&lt;/H2&gt;&lt;PRE&gt;using System;
using System.Collections.Generic;
using System.Text;
using System.Management;

&lt;SPAN style="COLOR: blue"&gt;namespace&lt;/SPAN&gt; Console_EnumSites_WMI_CSharp
{
    &lt;SPAN style="COLOR: blue"&gt;class&lt;/SPAN&gt; Program
    {
        &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; void Main(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt;[] args)
        {
            ManagementScope oms = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; ManagementScope(@&lt;SPAN style="COLOR: maroon"&gt;"\\.\root\MicrosoftIISv2"&lt;/SPAN&gt;);
            oms.Connect();

            ObjectQuery oQuery = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; ObjectQuery(&lt;SPAN style="COLOR: maroon"&gt;"select * from IISWebServerSetting"&lt;/SPAN&gt;);
            ManagementObjectSearcher oSearcher = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; ManagementObjectSearcher(oms, oQuery);
            foreach (ManagementObject oreturn &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; oSearcher.&lt;SPAN style="COLOR: blue"&gt;Get&lt;/SPAN&gt;())
            {
                Console.WriteLine(oreturn[&lt;SPAN style="COLOR: maroon"&gt;"ServerComment"&lt;/SPAN&gt;]+&lt;SPAN style="COLOR: maroon"&gt;" ("&lt;/SPAN&gt;+oreturn[&lt;SPAN style="COLOR: maroon"&gt;"Name"&lt;/SPAN&gt;]+&lt;SPAN style="COLOR: maroon"&gt;")"&lt;/SPAN&gt;);
            }
            Console.Read();
        }
    }
}
&lt;/PRE&gt;
&lt;HR&gt;

&lt;H2&gt;C# -Using Microsoft.Web.Administration ( II7 Only )&lt;/H2&gt;&lt;PRE&gt;using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Web.Administration;

&lt;SPAN style="COLOR: blue"&gt;namespace&lt;/SPAN&gt; Console_EnumSites
{
    &lt;SPAN style="COLOR: blue"&gt;class&lt;/SPAN&gt; Program
    {
        &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; void Main(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt;[] args)
        {
            ServerManager iisManager = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; ServerManager();

            Console.WriteLine(&lt;SPAN style="COLOR: maroon"&gt;"Display IIS Sites in IIS 7"&lt;/SPAN&gt;);
            Console.WriteLine(&lt;SPAN style="COLOR: maroon"&gt;""&lt;/SPAN&gt;.PadLeft(&lt;SPAN style="COLOR: maroon"&gt;40&lt;/SPAN&gt;,&lt;SPAN style="COLOR: green"&gt;'-'));&lt;/SPAN&gt;
            foreach(Site site &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; iisManager.Sites)
            {
                Console.WriteLine(&lt;SPAN style="COLOR: maroon"&gt;"{0} {1}"&lt;/SPAN&gt;, site.Id.ToString().PadRight(&lt;SPAN style="COLOR: maroon"&gt;12&lt;/SPAN&gt;), site.Name);                
            }
            Console.Read();
        }
    }
}
&lt;/PRE&gt;&lt;img src="http://blog.crowe.co.nz/aggbug/663.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Chris Crowe</dc:creator>
            <guid>http://blog.crowe.co.nz/archive/2006/07/04/663.aspx</guid>
            <pubDate>Mon, 03 Jul 2006 15:18:00 GMT</pubDate>
            <comments>http://blog.crowe.co.nz/archive/2006/07/04/663.aspx#feedback</comments>
            <slash:comments>4</slash:comments>
            <wfw:commentRss>http://blog.crowe.co.nz/comments/commentRss/663.aspx</wfw:commentRss>
        </item>
        <item>
            <title>c# - How to display the HttpExpires property and display its meaning...</title>
            <link>http://blog.crowe.co.nz/archive/2006/06/30/661.aspx</link>
            <description>&lt;P&gt;The HttpExpires property is documented at the following URL.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/3e1d9fbb-6910-4648-a2bb-11a945ca7980.mspx?mfr=true"&gt;http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/3e1d9fbb-6910-4648-a2bb-11a945ca7980.mspx?mfr=true&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;This simple c# console application will display the settings for the HttpExpires property at the root level of the default web site.&lt;/P&gt;
&lt;P&gt;Basically the value is encoded as follows:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;If the value is a blank string then there is no content expiry.&lt;BR&gt;&lt;/LI&gt;
&lt;LI&gt;If the value starts with a &lt;STRONG&gt;D&lt;/STRONG&gt;, then it is using a dynamic expiration period. This period is appended after the D and is stored as the number of seconds in hexidecimal format.&lt;BR&gt;&lt;BR&gt;&lt;STRONG&gt;Example: &amp;#8220;D, 0x15180&amp;#8221;&amp;nbsp;&amp;nbsp;&amp;nbsp; - this 0x15180 is the same as 86,400 seconds or 1 day.&lt;BR&gt;&lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI&gt;If the value starts with an &lt;STRONG&gt;S&lt;/STRONG&gt; then the following value is a GMT time of when the expiration will take place.&lt;BR&gt;&lt;BR&gt;&lt;STRONG&gt;Example:&amp;nbsp;&amp;#8220;S, Sat, 08 Jul 2006 12:00:00 GMT&amp;#8221;&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System;&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System.Collections.Generic;&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System.Text;&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System.DirectoryServices;&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;namespace&lt;/SPAN&gt; IISHTTPExpires&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;class&lt;/SPAN&gt; Program&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; Main(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt;[] args)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(&lt;SPAN style="COLOR: maroon"&gt;"IIS HTTP Expires - c#"&lt;/SPAN&gt;);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Serve to connect to...&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; ServerName = &lt;SPAN style="COLOR: maroon"&gt;"LocalHost"&lt;/SPAN&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Define the path to the metabase&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; MetabasePath = &lt;SPAN style="COLOR: maroon"&gt;"IIS://"&lt;/SPAN&gt; + ServerName + &lt;SPAN style="COLOR: maroon"&gt;"/W3SVC/1/ROOT"&lt;/SPAN&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;try&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Talk to the IIS Metabase to read the MimeMap Metabase key&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DirectoryEntry Entry = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; DirectoryEntry(MetabasePath);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Get the Mime Types as a collection&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PropertyValueCollection pvc = Entry.Properties[&lt;SPAN style="COLOR: maroon"&gt;"HTTPExpires"&lt;/SPAN&gt;];&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; HttpExpires = pvc.Value.ToString();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (HttpExpires.Length == &lt;SPAN style="COLOR: maroon"&gt;0&lt;/SPAN&gt;)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(&lt;SPAN style="COLOR: maroon"&gt;"HttpExpires is not enabled!"&lt;/SPAN&gt;);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;else&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;char&lt;/SPAN&gt; HttpExpiresType = HttpExpires[&lt;SPAN style="COLOR: maroon"&gt;0&lt;/SPAN&gt;];&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;switch&lt;/SPAN&gt; (HttpExpiresType)
                    {
                        &lt;SPAN style="COLOR: blue"&gt;case&lt;/SPAN&gt; &lt;SPAN style="COLOR: maroon"&gt;'D'&lt;/SPAN&gt;:&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; Seconds = HttpExpires.Substring(&lt;SPAN style="COLOR: maroon"&gt;3&lt;/SPAN&gt;);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (Seconds == &lt;SPAN style="COLOR: maroon"&gt;"0"&lt;/SPAN&gt;)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Seconds = &lt;SPAN style="COLOR: maroon"&gt;"Immediately"&lt;/SPAN&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;else&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (Seconds.StartsWith(&lt;SPAN style="COLOR: maroon"&gt;"0x"&lt;/SPAN&gt;)==&lt;SPAN style="COLOR: maroon"&gt;true&lt;/SPAN&gt;)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Seconds = &lt;SPAN style="COLOR: maroon"&gt;"in "&lt;/SPAN&gt; + &lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt;.Parse(HttpExpires.Substring(&lt;SPAN style="COLOR: maroon"&gt;5&lt;/SPAN&gt;), &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.Globalization.NumberStyles.HexNumber).ToString() + &lt;SPAN style="COLOR: maroon"&gt;" Seconds"&lt;/SPAN&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;else&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Seconds = &lt;SPAN style="COLOR: maroon"&gt;"in "&lt;/SPAN&gt; + Seconds + &lt;SPAN style="COLOR: maroon"&gt;" Seconds"&lt;/SPAN&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(&lt;SPAN style="COLOR: maroon"&gt;"HttpExpires {0}"&lt;/SPAN&gt;, Seconds);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;break&lt;/SPAN&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;case&lt;/SPAN&gt; &lt;SPAN style="COLOR: maroon"&gt;'S'&lt;/SPAN&gt;:&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(&lt;SPAN style="COLOR: maroon"&gt;"HttpExpires {0}"&lt;/SPAN&gt;, HttpExpires.Substring(&lt;SPAN style="COLOR: maroon"&gt;2&lt;/SPAN&gt;));&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;break&lt;/SPAN&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;default&lt;/SPAN&gt;:&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(&lt;SPAN style="COLOR: maroon"&gt;"Unknown HttpExpires Type : {0}"&lt;/SPAN&gt;, HttpExpiresType);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;break&lt;/SPAN&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;catch&lt;/SPAN&gt; (Exception ex)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(&lt;SPAN style="COLOR: maroon"&gt;"Failed to read HttpExpires property with the following exception: \n{0}"&lt;/SPAN&gt;,&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ex.Message);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;finally&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.Read();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;}&lt;/P&gt;&lt;img src="http://blog.crowe.co.nz/aggbug/661.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Chris Crowe</dc:creator>
            <guid>http://blog.crowe.co.nz/archive/2006/06/30/661.aspx</guid>
            <pubDate>Thu, 29 Jun 2006 16:38:00 GMT</pubDate>
            <comments>http://blog.crowe.co.nz/archive/2006/06/30/661.aspx#feedback</comments>
            <slash:comments>6</slash:comments>
            <wfw:commentRss>http://blog.crowe.co.nz/comments/commentRss/661.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>
