<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://detlefgrohs.com/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>WTF 3.12 : Coding</title><link>http://detlefgrohs.com/blogs/wtf312/archive/category/1005.aspx</link><description>General posts about coding in C#, VB.NET and/or Monad.</description><dc:language>en-US</dc:language><generator>CommunityServer 2.0 (Build: 60404.2676)</generator><item><title>C# Coalesce Exploration</title><link>http://detlefgrohs.com/blogs/wtf312/archive/2008/09/09/2829.aspx</link><pubDate>Tue, 09 Sep 2008 21:23:14 GMT</pubDate><guid isPermaLink="false">f696011e-ecde-4552-b492-c119587d7670:2829</guid><dc:creator>detlef</dc:creator><slash:comments>0</slash:comments><comments>http://detlefgrohs.com/blogs/wtf312/comments/2829.aspx</comments><wfw:commentRss>http://detlefgrohs.com/blogs/wtf312/commentrss.aspx?PostID=2829</wfw:commentRss><description>&lt;p&gt;Recording some exploration notes on the C# Coalesce operator (??) and also trying out &lt;a href="http://gallery.live.com/author.aspx?a=42558e43-f76f-42af-b824-ff34c98e1193"&gt;Leo Vildosola&lt;/a&gt;'s &lt;a title="Code Snippet plugin for Windows Live Writer" href="http://gallery.live.com/liveItemDetail.aspx?li=d4409446-af7f-42ec-aa20-78aa5bac4748&amp;amp;bt=9&amp;amp;pl=8"&gt;Code Snippet plugin for Windows Live Writer&lt;/a&gt;.&lt;/p&gt; &lt;table cellspacing="0" cellpadding="2"&gt;  &lt;tr&gt; &lt;td&gt; &lt;div&gt; &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 135%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; height: 84px; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Coalesce()&lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;object&lt;/span&gt; obj1 = &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;object&lt;/span&gt; obj2 = obj1 ?? &lt;span style="color: #0000ff"&gt;string&lt;/span&gt;.Empty;&lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt; }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;
&lt;td&gt;
&lt;div&gt;
&lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; .method &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; hidebysig &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Coalesce() cil managed&lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt;     .maxstack 2&lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;     .locals init (&lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt;         [0] &lt;span style="color: #0000ff"&gt;object&lt;/span&gt; obj1,&lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt;         [1] &lt;span style="color: #0000ff"&gt;object&lt;/span&gt; obj2)&lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt;     L_0000: nop &lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   8:&lt;/span&gt;     L_0001: ldnull &lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   9:&lt;/span&gt;     L_0002: stloc.0 &lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  10:&lt;/span&gt;     L_0003: ldloc.0 &lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  11:&lt;/span&gt;     L_0004: dup &lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  12:&lt;/span&gt;     L_0005: brtrue.s L_000d&lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  13:&lt;/span&gt;     L_0007: pop &lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  14:&lt;/span&gt;     L_0008: ldsfld &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; [mscorlib]System.String::Empty&lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  15:&lt;/span&gt;     L_000d: stloc.1 &lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  16:&lt;/span&gt;     L_000e: ret &lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  17:&lt;/span&gt; }&lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  18:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;div&gt;
&lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; ManualCoalesce()&lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;object&lt;/span&gt; obj1 = &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;object&lt;/span&gt; obj2 = obj1 != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt; ? obj1 : &lt;span style="color: #0000ff"&gt;string&lt;/span&gt;.Empty;&lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt; }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;
&lt;td&gt;
&lt;div&gt;
&lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; .method &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; hidebysig &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; ManualCoalesce() cil managed&lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt;     .maxstack 2&lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;     .locals init (&lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt;         [0] &lt;span style="color: #0000ff"&gt;object&lt;/span&gt; obj1,&lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt;         [1] &lt;span style="color: #0000ff"&gt;object&lt;/span&gt; obj2)&lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt;     L_0000: nop &lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   8:&lt;/span&gt;     L_0001: ldnull &lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   9:&lt;/span&gt;     L_0002: stloc.0 &lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  10:&lt;/span&gt;     L_0003: ldloc.0 &lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  11:&lt;/span&gt;     L_0004: brtrue.s L_000d&lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  12:&lt;/span&gt;     L_0006: ldsfld &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; [mscorlib]System.String::Empty&lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  13:&lt;/span&gt;     L_000b: br.s L_000e&lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  14:&lt;/span&gt;     L_000d: ldloc.0 &lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  15:&lt;/span&gt;     L_000e: stloc.1 &lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  16:&lt;/span&gt;     L_000f: ret &lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  17:&lt;/span&gt; }&lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  18:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  19:&lt;/span&gt;  &lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;img src="http://detlefgrohs.com/aggbug.aspx?PostID=2829" width="1" height="1"&gt;</description><category domain="http://detlefgrohs.com/blogs/wtf312/archive/category/1005.aspx">Coding</category></item><item><title>Regular Expression Resources</title><link>http://detlefgrohs.com/blogs/wtf312/archive/2007/10/30/200.aspx</link><pubDate>Tue, 30 Oct 2007 16:16:37 GMT</pubDate><guid isPermaLink="false">f696011e-ecde-4552-b492-c119587d7670:200</guid><dc:creator>detlef</dc:creator><slash:comments>0</slash:comments><comments>http://detlefgrohs.com/blogs/wtf312/comments/200.aspx</comments><wfw:commentRss>http://detlefgrohs.com/blogs/wtf312/commentrss.aspx?PostID=200</wfw:commentRss><description>&lt;p&gt;A collection of regular expression tools and references for my reference. I will be incorporating this into my tools and reference list.&lt;/p&gt; &lt;h1&gt;Tools&lt;/h1&gt; &lt;p&gt;&lt;a href="http://www.ultrapico.com/Expresso.htm"&gt;Expresso 3.0&lt;/a&gt; - A great regular expression builder and analyzer tool.&lt;/p&gt; &lt;p&gt;&lt;a href="http://tools.osherove.com/CoolTools/Regulator/tabid/185/Default.aspx"&gt;The Regulator&lt;/a&gt; - A regular expression testing tool.&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.regexbuddy.com/create.html"&gt;RegExBuddy&lt;/a&gt; - Builder for regular expressions. Linked with the Regular-Expressions.info reference site below.&lt;/p&gt; &lt;h1&gt;References&lt;/h1&gt; &lt;p&gt;&lt;a href="http://www.regular-expressions.info/reference.html"&gt;Regular-Expressions.info&lt;/a&gt; - Nice online reference to regular expression syntax. See the RegExBuddy above.&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.visibone.com/regular-expressions/"&gt;VisiBone Regular Expressions Reference Card&lt;/a&gt; - Online reference card available. This site also has other great reference cards available.&lt;/p&gt;&lt;img src="http://detlefgrohs.com/aggbug.aspx?PostID=200" width="1" height="1"&gt;</description><category domain="http://detlefgrohs.com/blogs/wtf312/archive/category/1014.aspx">.NET</category><category domain="http://detlefgrohs.com/blogs/wtf312/archive/category/1005.aspx">Coding</category></item><item><title>Beautiful Code</title><link>http://detlefgrohs.com/blogs/wtf312/archive/2007/10/27/196.aspx</link><pubDate>Sat, 27 Oct 2007 20:50:20 GMT</pubDate><guid isPermaLink="false">f696011e-ecde-4552-b492-c119587d7670:196</guid><dc:creator>detlef</dc:creator><slash:comments>0</slash:comments><comments>http://detlefgrohs.com/blogs/wtf312/comments/196.aspx</comments><wfw:commentRss>http://detlefgrohs.com/blogs/wtf312/commentrss.aspx?PostID=196</wfw:commentRss><description>&lt;p&gt;I picked up &lt;b&gt;&lt;a href="http://www.amazon.com/Beautiful-Code-Leading-Programmers-Practice/dp/0596510047/ref=pd_bbs_sr_1/105-7177919-0867601?ie=UTF8&amp;amp;s=books&amp;amp;qid=1193506582&amp;amp;sr=8-1"&gt;Beautiful Code: Leading Programmers Explain How They Think&lt;/a&gt; &lt;/b&gt;from Borders last week and I have been enjoying it. It has awakened a need to play around with code again that is not directly related to my work. I like that the book is really a collection of essays. This separation of the topics makes it perfect for reading in short bursts and you are not stuck on a topic you are not interested in for too long. I have not hit a topic that I found boring yet so this has not posed a problem.&lt;/p&gt;&lt;img src="http://detlefgrohs.com/aggbug.aspx?PostID=196" width="1" height="1"&gt;</description><category domain="http://detlefgrohs.com/blogs/wtf312/archive/category/1005.aspx">Coding</category></item><item><title>Host Application Code for Old XMLDocumentSplitter Class</title><link>http://detlefgrohs.com/blogs/wtf312/archive/2007/10/03/163.aspx</link><pubDate>Wed, 03 Oct 2007 16:13:41 GMT</pubDate><guid isPermaLink="false">f696011e-ecde-4552-b492-c119587d7670:163</guid><dc:creator>detlef</dc:creator><slash:comments>0</slash:comments><comments>http://detlefgrohs.com/blogs/wtf312/comments/163.aspx</comments><wfw:commentRss>http://detlefgrohs.com/blogs/wtf312/commentrss.aspx?PostID=163</wfw:commentRss><description>&lt;p&gt;I am including the code from my original host application for my XMLDocumentSplitter class. I will be updating this along with the utility class as well. It is interesting to see some of my coding habits from years ago.&lt;/p&gt; &lt;p&gt;&lt;a href="http://detlefgrohs.com/blogs/files/HostApplicationCodeforOldXMLDocumentSpli_12920/XMLSplitter.gif"&gt;&lt;img height="308" alt="XMLSplitter" src="http://detlefgrohs.com/blogs/files/HostApplicationCodeforOldXMLDocumentSpli_12920/XMLSplitter_thumb.gif" width="308" border="0"&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt; &lt;hr&gt;  &lt;p&gt;&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: rgb(0,0,255)"&gt;Public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Class&lt;/span&gt; frmMain
    &lt;span style="color: rgb(0,0,255)"&gt;Inherits&lt;/span&gt; System.Windows.Forms.Form

#&lt;span style="color: rgb(0,0,255)"&gt;Region&lt;/span&gt; &lt;span style="color: rgb(163,21,21)"&gt;" Windows Form Designer generated code "    &lt;/span&gt;&lt;/pre&gt;&lt;pre class="code"&gt;&lt;span style="color: rgb(0,128,0)"&gt;' VS Generated Code Removed&lt;/span&gt;&lt;span style="color: rgb(163,21,21)"&gt;
&lt;/span&gt;#&lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Region

&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Private&lt;/span&gt; m_XMLSplitter &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;New&lt;/span&gt; XMLDocumentSplitter()

    &lt;span style="color: rgb(0,0,255)"&gt;Private&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Sub&lt;/span&gt; btnSplit_Click(&lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; System.Object, &lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; e &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; System.EventArgs) &lt;span style="color: rgb(0,0,255)"&gt;Handles&lt;/span&gt; btnSplit.Click
        &lt;span style="color: rgb(0,0,255)"&gt;If&lt;/span&gt; rbSplitByDocumentSize.Checked &lt;span style="color: rgb(0,0,255)"&gt;Then
&lt;/span&gt;            m_XMLSplitter.SplitType = XMLDocumentSplitter.SplitTypes.ByDocumentSize
            m_XMLSplitter.SplitSize = &lt;span style="color: rgb(0,0,255)"&gt;CType&lt;/span&gt;(txtDocumentSize.Text, &lt;span style="color: rgb(0,0,255)"&gt;Long&lt;/span&gt;)
        &lt;span style="color: rgb(0,0,255)"&gt;Else
&lt;/span&gt;            m_XMLSplitter.SplitType = XMLDocumentSplitter.SplitTypes.ByElementCount
            m_XMLSplitter.SplitSize = &lt;span style="color: rgb(0,0,255)"&gt;CType&lt;/span&gt;(txtElementCount.Text, &lt;span style="color: rgb(0,0,255)"&gt;Long&lt;/span&gt;)
        &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;If

&lt;/span&gt;        m_XMLSplitter.Split(&lt;span style="color: rgb(0,0,255)"&gt;New&lt;/span&gt; System.IO.StreamReader(txtSourceDocument.Text), &lt;span style="color: rgb(0,0,255)"&gt;AddressOf&lt;/span&gt; SplitHandler)

        MessageBox.Show(&lt;span style="color: rgb(0,0,255)"&gt;String&lt;/span&gt;.Format(&lt;span style="color: rgb(163,21,21)"&gt;"Split '{0}' into {1} files."&lt;/span&gt;, txtSourceDocument.Text, m_XMLSplitter.SplitCount))
    &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Sub

&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Private&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Sub&lt;/span&gt; SplitHandler(&lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; count &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Long&lt;/span&gt;, &lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; document &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;String&lt;/span&gt;)
        &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; stream_writer &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;New&lt;/span&gt; System.IO.StreamWriter(txtDestinationPath.Text &amp;amp; &lt;span style="color: rgb(0,0,255)"&gt;String&lt;/span&gt;.Format(txtDestinationFilenamePattern.Text, count))
        stream_writer.Write(document)
        stream_writer.Close()
    &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Sub

&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Private&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Sub&lt;/span&gt; FieldFields_TextChanged(&lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; System.Object, &lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; e &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; System.EventArgs) _
            &lt;span style="color: rgb(0,0,255)"&gt;Handles&lt;/span&gt; txtSourceDocument.TextChanged, txtDestinationPath.TextChanged, txtDestinationFilenamePattern.TextChanged
        AdjustSplitButton()
    &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Sub

&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Private&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Sub&lt;/span&gt; AdjustSplitButton()
        &lt;span style="color: rgb(0,0,255)"&gt;If&lt;/span&gt; System.IO.File.Exists(txtSourceDocument.Text) &lt;span style="color: rgb(0,0,255)"&gt;And&lt;/span&gt; _
            System.IO.Directory.Exists(txtDestinationPath.Text) &lt;span style="color: rgb(0,0,255)"&gt;And&lt;/span&gt; _
            ValidPattern(txtDestinationFilenamePattern.Text) &lt;span style="color: rgb(0,0,255)"&gt;Then
&lt;/span&gt;            btnSplit.Enabled = &lt;span style="color: rgb(0,0,255)"&gt;True
&lt;/span&gt;        &lt;span style="color: rgb(0,0,255)"&gt;Else
&lt;/span&gt;            btnSplit.Enabled = &lt;span style="color: rgb(0,0,255)"&gt;False
&lt;/span&gt;        &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;If
&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Sub

&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Private&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Function&lt;/span&gt; ValidPattern(&lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; pattern &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;String&lt;/span&gt;) &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Boolean
&lt;/span&gt;        &lt;span style="color: rgb(0,128,0)"&gt;' Pattern needs to contain '{0.*}' - very basic checking...
&lt;/span&gt;        &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; regexp &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;New&lt;/span&gt; System.Text.RegularExpressions.Regex(&lt;span style="color: rgb(163,21,21)"&gt;"\{0.*\}"&lt;/span&gt;)
        &lt;span style="color: rgb(0,0,255)"&gt;Return&lt;/span&gt; regexp.IsMatch(pattern)
    &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Function

&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Private&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Sub&lt;/span&gt; frmMain_Load(&lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; System.Object, &lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; e &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; System.EventArgs) &lt;span style="color: rgb(0,0,255)"&gt;Handles&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;MyBase&lt;/span&gt;.Load
        AdjustSplitButton()
    &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Sub

&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Private&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Sub&lt;/span&gt; btnExit_Click(&lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; System.Object, &lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; e &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; System.EventArgs) &lt;span style="color: rgb(0,0,255)"&gt;Handles&lt;/span&gt; btnExit.Click
        &lt;span style="color: rgb(0,0,255)"&gt;Me&lt;/span&gt;.Close()
    &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Sub

&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Private&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Sub&lt;/span&gt; RadioButtons_CheckedChanged(&lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; System.Object, &lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; e &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; System.EventArgs) _
        &lt;span style="color: rgb(0,0,255)"&gt;Handles&lt;/span&gt; rbSplitByDocumentSize.CheckedChanged, rbSplitByElementCount.CheckedChanged
        &lt;span style="color: rgb(0,0,255)"&gt;If&lt;/span&gt; rbSplitByDocumentSize.Checked &lt;span style="color: rgb(0,0,255)"&gt;Then
&lt;/span&gt;            txtDocumentSize.Enabled = &lt;span style="color: rgb(0,0,255)"&gt;True&lt;/span&gt; : txtElementCount.Enabled = &lt;span style="color: rgb(0,0,255)"&gt;False
&lt;/span&gt;        &lt;span style="color: rgb(0,0,255)"&gt;Else
&lt;/span&gt;            txtDocumentSize.Enabled = &lt;span style="color: rgb(0,0,255)"&gt;False&lt;/span&gt; : txtElementCount.Enabled = &lt;span style="color: rgb(0,0,255)"&gt;True
&lt;/span&gt;        &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;If
&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Sub

&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Private&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Sub&lt;/span&gt; btnSourceDocument_Click(&lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; System.Object, &lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; e &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; System.EventArgs) &lt;span style="color: rgb(0,0,255)"&gt;Handles&lt;/span&gt; btnSourceDocument.Click
        &lt;span style="color: rgb(0,128,0)"&gt;' Get Source File Information
&lt;/span&gt;        dlgOpenFile.FileName = txtSourceDocument.Text
        &lt;span style="color: rgb(0,0,255)"&gt;If&lt;/span&gt; dlgOpenFile.ShowDialog() = DialogResult.OK &lt;span style="color: rgb(0,0,255)"&gt;Then
&lt;/span&gt;            txtSourceDocument.Text = dlgOpenFile.FileName
        &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;If
&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Sub

&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Private&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Sub&lt;/span&gt; btnDestinationPath_Click(&lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; System.Object, &lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; e &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; System.EventArgs) &lt;span style="color: rgb(0,0,255)"&gt;Handles&lt;/span&gt; btnDestinationPath.Click
        &lt;span style="color: rgb(0,128,0)"&gt;' Get Destination Path Information
&lt;/span&gt;        dlgSaveFile.InitialDirectory = txtDestinationPath.Text
        &lt;span style="color: rgb(0,0,255)"&gt;If&lt;/span&gt; dlgSaveFile.ShowDialog = DialogResult.OK &lt;span style="color: rgb(0,0,255)"&gt;Then
&lt;/span&gt;            txtDestinationPath.Text = dlgSaveFile.FileName
        &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;If
&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Sub
End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Class
&lt;/span&gt;&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;img src="http://detlefgrohs.com/aggbug.aspx?PostID=163" width="1" height="1"&gt;</description><category domain="http://detlefgrohs.com/blogs/wtf312/archive/category/1014.aspx">.NET</category><category domain="http://detlefgrohs.com/blogs/wtf312/archive/category/1005.aspx">Coding</category></item><item><title>My Old XMLDocumentSplitter Class</title><link>http://detlefgrohs.com/blogs/wtf312/archive/2007/10/02/162.aspx</link><pubDate>Tue, 02 Oct 2007 15:58:28 GMT</pubDate><guid isPermaLink="false">f696011e-ecde-4552-b492-c119587d7670:162</guid><dc:creator>detlef</dc:creator><slash:comments>0</slash:comments><comments>http://detlefgrohs.com/blogs/wtf312/comments/162.aspx</comments><wfw:commentRss>http://detlefgrohs.com/blogs/wtf312/commentrss.aspx?PostID=162</wfw:commentRss><description>&lt;p&gt;I have resurrected my old XMLDocumentSplitter class from Code Project and am planning on updating it. These are on my list of things I need to bring this up to date:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Write both C# and VB.NET versions  &lt;li&gt;Use an Event handler method for handling the chunks  &lt;li&gt;Use the .NET 2.0 Framework and see what changes the have been made to the XmlTextReader and XmlTextWriter classes from 1.0  &lt;li&gt;Better error handling  &lt;li&gt;Some kind of unit testing framework to automatically test the class for regular and boundary conditions  &lt;li&gt;Update GUI and command line host applications for the class  &lt;li&gt;Updated article with what I have learned since I first wrote this class&lt;/li&gt;&lt;/ol&gt; &lt;hr&gt; &lt;pre class="code"&gt;&lt;span style="color: rgb(0,0,255)"&gt;Imports&lt;/span&gt; System.IO
&lt;span style="color: rgb(0,0,255)"&gt;Imports&lt;/span&gt; System.Xml

&lt;span style="color: rgb(0,0,255)"&gt;Public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Class&lt;/span&gt; XMLDocumentSplitter
#&lt;span style="color: rgb(0,0,255)"&gt;Region&lt;/span&gt; &lt;span style="color: rgb(163,21,21)"&gt;"Private and Public Declarations"
&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Private&lt;/span&gt; m_SplitType &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; SplitTypes
    &lt;span style="color: rgb(0,0,255)"&gt;Private&lt;/span&gt; m_SplitSize &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Long
&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Private&lt;/span&gt; m_SplitCount &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Long
&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Private&lt;/span&gt; m_TotalSplitSizes &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Long

&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Enum&lt;/span&gt; SplitTypes
        ByDocumentSize
        ByElementCount
    &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Enum
&lt;/span&gt;#&lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Region
&lt;/span&gt;#&lt;span style="color: rgb(0,0,255)"&gt;Region&lt;/span&gt; &lt;span style="color: rgb(163,21,21)"&gt;"Constructors, Destructors and Initialization"
&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Sub&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;New&lt;/span&gt;(&lt;span style="color: rgb(0,0,255)"&gt;Optional&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; split_type &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; SplitTypes = SplitTypes.ByDocumentSize, _
                    &lt;span style="color: rgb(0,0,255)"&gt;Optional&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; split_size &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Long&lt;/span&gt; = 512000)
        m_SplitType = split_type : m_SplitSize = split_size
    &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Sub
&lt;/span&gt;#&lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Region
&lt;/span&gt;#&lt;span style="color: rgb(0,0,255)"&gt;Region&lt;/span&gt; &lt;span style="color: rgb(163,21,21)"&gt;"Properties"
&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Property&lt;/span&gt; SplitType() &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; SplitTypes
        &lt;span style="color: rgb(0,0,255)"&gt;Get
&lt;/span&gt;            &lt;span style="color: rgb(0,0,255)"&gt;Return&lt;/span&gt; m_SplitType
        &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Get
&lt;/span&gt;        &lt;span style="color: rgb(0,0,255)"&gt;Set&lt;/span&gt;(&lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; Value &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; SplitTypes)
            m_SplitType = Value
        &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Set
&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Property

&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Property&lt;/span&gt; SplitSize() &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Long
&lt;/span&gt;        &lt;span style="color: rgb(0,0,255)"&gt;Get
&lt;/span&gt;            &lt;span style="color: rgb(0,0,255)"&gt;Return&lt;/span&gt; m_SplitSize
        &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Get
&lt;/span&gt;        &lt;span style="color: rgb(0,0,255)"&gt;Set&lt;/span&gt;(&lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; Value &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Long&lt;/span&gt;)
            m_SplitSize = Value
        &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Set
&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Property

&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;ReadOnly&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Property&lt;/span&gt; SplitCount() &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Long
&lt;/span&gt;        &lt;span style="color: rgb(0,0,255)"&gt;Get
&lt;/span&gt;            &lt;span style="color: rgb(0,0,255)"&gt;Return&lt;/span&gt; m_SplitCount
        &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Get
&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Property

&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;ReadOnly&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Property&lt;/span&gt; TotalSplitSizes() &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Long
&lt;/span&gt;        &lt;span style="color: rgb(0,0,255)"&gt;Get
&lt;/span&gt;            &lt;span style="color: rgb(0,0,255)"&gt;Return&lt;/span&gt; m_TotalSplitSizes
        &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Get
&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Property
&lt;/span&gt;#&lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Region
&lt;/span&gt;#&lt;span style="color: rgb(0,0,255)"&gt;Region&lt;/span&gt; &lt;span style="color: rgb(163,21,21)"&gt;"Public Methods"
&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Sub&lt;/span&gt; Split(&lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; text_reader &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; TextReader, &lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; handler &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; XMLDocumentSplitHandler)
        &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; document_header &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;String&lt;/span&gt;, document_footer &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;String
&lt;/span&gt;        &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; element_counter &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Long&lt;/span&gt; = 0 : m_SplitCount = 0 : m_TotalSplitSizes = 0
        &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; empty_document &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Boolean&lt;/span&gt; = &lt;span style="color: rgb(0,0,255)"&gt;False&lt;/span&gt; &lt;span style="color: rgb(0,128,0)"&gt;' First time through is never an empty document
&lt;/span&gt;        &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; string_builder &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;New&lt;/span&gt; System.Text.StringBuilder
        &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; xml_text_writer &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;New&lt;/span&gt; XmlTextWriter(&lt;span style="color: rgb(0,0,255)"&gt;New&lt;/span&gt; StringWriter(string_builder))
        &lt;span style="color: rgb(0,0,255)"&gt;Dim&lt;/span&gt; xml_text_reader &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;New&lt;/span&gt; XmlTextReader(text_reader)
        xml_text_reader.Read() &lt;span style="color: rgb(0,128,0)"&gt;' prime the pump

&lt;/span&gt;        &lt;span style="color: rgb(0,128,0)"&gt;' Capture all of the items before the first element...
&lt;/span&gt;        &lt;span style="color: rgb(0,0,255)"&gt;While&lt;/span&gt; xml_text_reader.NodeType &amp;lt;&amp;gt; XmlNodeType.Element
            xml_text_writer.WriteNode(xml_text_reader, &lt;span style="color: rgb(0,0,255)"&gt;True&lt;/span&gt;)
        &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;While

&lt;/span&gt;        &lt;span style="color: rgb(0,128,0)"&gt;' Prepare the document header and footer sections for use later...
&lt;/span&gt;        xml_text_writer.WriteStartElement(xml_text_reader.Name)
        xml_text_writer.WriteAttributes(xml_text_reader, &lt;span style="color: rgb(0,0,255)"&gt;True&lt;/span&gt;)
        document_header = string_builder.ToString &amp;amp; &lt;span style="color: rgb(163,21,21)"&gt;"&amp;gt;"&lt;/span&gt; &lt;span style="color: rgb(0,128,0)"&gt;' Must close this manually...
&lt;/span&gt;        document_footer = vbCrLf &amp;amp; &lt;span style="color: rgb(163,21,21)"&gt;"&amp;lt;/"&lt;/span&gt; &amp;amp; xml_text_reader.Name &amp;amp; &lt;span style="color: rgb(163,21,21)"&gt;"&amp;gt;"&lt;/span&gt; &lt;span style="color: rgb(0,128,0)"&gt;' Create close element manually...
&lt;/span&gt;        xml_text_reader.Read() &lt;span style="color: rgb(0,128,0)"&gt;' Skip past the root node...

&lt;/span&gt;        &lt;span style="color: rgb(0,0,255)"&gt;While&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Not&lt;/span&gt; xml_text_reader.EOF
            &lt;span style="color: rgb(0,128,0)"&gt;' Only count the nodes that interest us...
&lt;/span&gt;            &lt;span style="color: rgb(0,0,255)"&gt;If&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Not&lt;/span&gt; IgnorableNodeType(xml_text_reader.NodeType) &lt;span style="color: rgb(0,0,255)"&gt;Then&lt;/span&gt; element_counter += 1 : empty_document = &lt;span style="color: rgb(0,0,255)"&gt;False
&lt;/span&gt;            xml_text_writer.WriteNode(xml_text_reader, &lt;span style="color: rgb(0,0,255)"&gt;True&lt;/span&gt;) &lt;span style="color: rgb(0,128,0)"&gt;' Copy everything from the reader to the writer

&lt;/span&gt;            &lt;span style="color: rgb(0,0,255)"&gt;If&lt;/span&gt; (m_SplitType = SplitTypes.ByDocumentSize &lt;span style="color: rgb(0,0,255)"&gt;And&lt;/span&gt; (string_builder.Length - document_header.Length) &amp;gt;= m_SplitSize) &lt;span style="color: rgb(0,0,255)"&gt;OrElse&lt;/span&gt; _
                (m_SplitType = SplitTypes.ByElementCount &lt;span style="color: rgb(0,0,255)"&gt;And&lt;/span&gt; element_counter &amp;gt;= m_SplitSize) &lt;span style="color: rgb(0,0,255)"&gt;Then
&lt;/span&gt;                handler(m_SplitCount, string_builder.ToString &amp;amp; document_footer)
                m_TotalSplitSizes += string_builder.Length : m_SplitCount += 1 : element_counter = 0 &lt;span style="color: rgb(0,128,0)"&gt;' Adjust the counters
&lt;/span&gt;                string_builder.Length = 0 : string_builder.Append(document_header) &lt;span style="color: rgb(0,128,0)"&gt;' Reset the StringBuilder
&lt;/span&gt;                empty_document = &lt;span style="color: rgb(0,0,255)"&gt;True&lt;/span&gt; &lt;span style="color: rgb(0,128,0)"&gt;' It is an empty document again...
&lt;/span&gt;            &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;If
&lt;/span&gt;        &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;While

&lt;/span&gt;        &lt;span style="color: rgb(0,0,255)"&gt;If&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Not&lt;/span&gt; empty_document &lt;span style="color: rgb(0,0,255)"&gt;Then
&lt;/span&gt;            handler(m_SplitCount, string_builder.ToString &amp;amp; document_footer)
            m_TotalSplitSizes += string_builder.Length : m_SplitCount += 1 &lt;span style="color: rgb(0,128,0)"&gt;' Adjust the counters
&lt;/span&gt;        &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;If
&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Sub
&lt;/span&gt;#&lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Region
&lt;/span&gt;#&lt;span style="color: rgb(0,0,255)"&gt;Region&lt;/span&gt; &lt;span style="color: rgb(163,21,21)"&gt;"Private Methods"
&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Private&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Function&lt;/span&gt; IgnorableNodeType(&lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; node_type &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; XmlNodeType) &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Boolean
&lt;/span&gt;        &lt;span style="color: rgb(0,0,255)"&gt;If&lt;/span&gt; node_type = XmlNodeType.Whitespace &lt;span style="color: rgb(0,0,255)"&gt;OrElse&lt;/span&gt; _
            node_type = XmlNodeType.SignificantWhitespace &lt;span style="color: rgb(0,0,255)"&gt;OrElse&lt;/span&gt; _
            node_type = XmlNodeType.EndEntity &lt;span style="color: rgb(0,0,255)"&gt;OrElse&lt;/span&gt; _
            node_type = XmlNodeType.EndElement &lt;span style="color: rgb(0,0,255)"&gt;Then
&lt;/span&gt;            &lt;span style="color: rgb(0,0,255)"&gt;Return&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;True
&lt;/span&gt;        &lt;span style="color: rgb(0,0,255)"&gt;Else
&lt;/span&gt;            &lt;span style="color: rgb(0,0,255)"&gt;Return&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;False
&lt;/span&gt;        &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;If
&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Function
&lt;/span&gt;#&lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Region
End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Class

Public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Delegate&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Sub&lt;/span&gt; XMLDocumentSplitHandler(&lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; count &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Long&lt;/span&gt;, &lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; document &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;String&lt;/span&gt;)
&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;img src="http://detlefgrohs.com/aggbug.aspx?PostID=162" width="1" height="1"&gt;</description><category domain="http://detlefgrohs.com/blogs/wtf312/archive/category/1014.aspx">.NET</category><category domain="http://detlefgrohs.com/blogs/wtf312/archive/category/1005.aspx">Coding</category></item><item><title>Revisiting Old Code</title><link>http://detlefgrohs.com/blogs/wtf312/archive/2007/10/01/161.aspx</link><pubDate>Mon, 01 Oct 2007 13:47:35 GMT</pubDate><guid isPermaLink="false">f696011e-ecde-4552-b492-c119587d7670:161</guid><dc:creator>detlef</dc:creator><slash:comments>0</slash:comments><comments>http://detlefgrohs.com/blogs/wtf312/comments/161.aspx</comments><wfw:commentRss>http://detlefgrohs.com/blogs/wtf312/commentrss.aspx?PostID=161</wfw:commentRss><description>&lt;p&gt;I was doing an &lt;a href="http://en.wikipedia.org/wiki/Egosurfing" target="_blank"&gt;ego search&lt;/a&gt; and found some of my old articles that I posted to Code Project a long time ago: &lt;a title="Single Instance Application in VB.NET" href="http://www.codeproject.com/vb/net/sing_inistan.asp"&gt;Single Instance Application in VB.NET&lt;/a&gt; and &lt;a title="XML Document Splitter Class" href="http://www.codeproject.com/vb/net/xmlsplitter.asp"&gt;XML Document Splitter Class&lt;/a&gt;. I have decided to take a look at the code and update it this week for Visual Studio 2005 and post it to my blog. I want to update these to see what new methods in the Framework exist and also to create both a VB.NET and C# version for reference.&lt;/p&gt; &lt;p&gt;I also need to post pieces of the code that I wrote for the Transform application that I wrote and some of the other help applications/classes/methods. Need to make an organized effort to collect and document all of these in one place.&lt;/p&gt; &lt;p&gt;&lt;em&gt;0534.2690&lt;/em&gt;&lt;/p&gt;&lt;img src="http://detlefgrohs.com/aggbug.aspx?PostID=161" width="1" height="1"&gt;</description><category domain="http://detlefgrohs.com/blogs/wtf312/archive/category/1014.aspx">.NET</category><category domain="http://detlefgrohs.com/blogs/wtf312/archive/category/1005.aspx">Coding</category></item><item><title>Code Beautifiers</title><link>http://detlefgrohs.com/blogs/wtf312/archive/2007/09/27/154.aspx</link><pubDate>Thu, 27 Sep 2007 15:49:06 GMT</pubDate><guid isPermaLink="false">f696011e-ecde-4552-b492-c119587d7670:154</guid><dc:creator>detlef</dc:creator><slash:comments>0</slash:comments><comments>http://detlefgrohs.com/blogs/wtf312/comments/154.aspx</comments><wfw:commentRss>http://detlefgrohs.com/blogs/wtf312/commentrss.aspx?PostID=154</wfw:commentRss><description>&lt;p&gt; I might be doing some JavaScript client side programming for my next project, so I saw this &lt;a href="http://elfz.laacz.lv/beautify/?" target="_blank"&gt;My Great Free Online Beautifier for JavaScript&lt;/a&gt; that I need to save a reference to. I then starting thinking that I have seen other online code beautifiers before and wonder what was out on the net and found this &lt;a href="http://www.smashingmagazine.com/2007/07/12/time-savers-code-beautifier-and-formatter/"&gt;Time-Savers: Code Beautifier And Formatter&lt;/a&gt;. I think the &lt;a href="http://quickhighlighter.com/" target="_blank"&gt;QuickHighlighter&lt;/a&gt; looks the most interesting. I will have to look through the rest of the entries and see what is useful.&lt;/p&gt; &lt;p&gt; I was testing how the beautified items would paste into Windows Live Writer from QuickHighlighter and I finally had to tell it to use embedded styles and pasted the html code directly into the html of the post. It looks good though:&lt;/p&gt; &lt;div class="csharp" style="border-right: #d0d0d0 1px solid; border-top: #d0d0d0 1px solid; border-left: #d0d0d0 1px solid; color: #006; border-bottom: #d0d0d0 1px solid; font-family: monospace; background-color: #f0f0f0"&gt;output.&lt;span style="color: #0000ff"&gt;WriteLine&lt;/span&gt;&lt;span style="color: #000000"&gt;(&lt;/span&gt;spweb.&lt;span style="color: #0000ff"&gt;Url&lt;/span&gt; + &lt;span style="color: #808080"&gt;"/Lists/"&lt;/span&gt; + item.&lt;span style="color: #0000ff"&gt;ParentList&lt;/span&gt;.&lt;span style="color: #0000ff"&gt;Title&lt;/span&gt; + &lt;span style="color: #808080"&gt;"/EditForm.aspx?ID="&lt;/span&gt; + item.&lt;span style="color: #0000ff"&gt;ID&lt;/span&gt;&lt;span style="color: #000000"&gt;)&lt;/span&gt;; &lt;br&gt;&lt;/div&gt; &lt;p&gt; Insert from Visual Studio is still easier, but for other quick code snippets that are not C# or VB.NET, I think this will be very useful. I have some t-sql snippets I need to capture.&lt;/p&gt;&lt;img src="http://detlefgrohs.com/aggbug.aspx?PostID=154" width="1" height="1"&gt;</description><category domain="http://detlefgrohs.com/blogs/wtf312/archive/category/1005.aspx">Coding</category></item><item><title>TransformTester</title><link>http://detlefgrohs.com/blogs/wtf312/archive/2007/06/11/138.aspx</link><pubDate>Mon, 11 Jun 2007 12:40:41 GMT</pubDate><guid isPermaLink="false">f696011e-ecde-4552-b492-c119587d7670:138</guid><dc:creator>detlef</dc:creator><slash:comments>0</slash:comments><comments>http://detlefgrohs.com/blogs/wtf312/comments/138.aspx</comments><wfw:commentRss>http://detlefgrohs.com/blogs/wtf312/commentrss.aspx?PostID=138</wfw:commentRss><description>&lt;p&gt;I have added the source code and binaries for my TransformTester application to the site. The downloads can be found &lt;a href="http://detlefgrohs.com/files/7/transformtester/default.aspx" target="_blank"&gt;here&lt;/a&gt;. Of note, is that I started to add syntax highlighting and code completion to the application. I am still working on these classes to expand their coverage. Will post more about this application later.&lt;/p&gt; &lt;p&gt;&lt;a href="http://detlefgrohs.com/blogs/files/TransformTester_4F93/image.png"&gt;&lt;img height="537" alt="image" src="http://detlefgrohs.com/blogs/files/TransformTester_4F93/image_thumb.png" width="688" border="0"&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://detlefgrohs.com/aggbug.aspx?PostID=138" width="1" height="1"&gt;</description><category domain="http://detlefgrohs.com/blogs/wtf312/archive/category/1005.aspx">Coding</category></item><item><title>Code Post Test #3</title><link>http://detlefgrohs.com/blogs/wtf312/archive/2007/06/10/132.aspx</link><pubDate>Sun, 10 Jun 2007 14:53:39 GMT</pubDate><guid isPermaLink="false">f696011e-ecde-4552-b492-c119587d7670:132</guid><dc:creator>detlef</dc:creator><slash:comments>0</slash:comments><comments>http://detlefgrohs.com/blogs/wtf312/comments/132.aspx</comments><wfw:commentRss>http://detlefgrohs.com/blogs/wtf312/commentrss.aspx?PostID=132</wfw:commentRss><description>&lt;p&gt;My third code post test:&lt;/p&gt; &lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; Form1()&lt;/pre&gt;&lt;pre&gt;        {&lt;/pre&gt;&lt;pre class="alt"&gt;            InitializeComponent();&lt;/pre&gt;&lt;pre&gt;        }&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I am using the &lt;a href="http://blogs.msdn.com/mikeormond/archive/2006/08/24/716900.aspx" target="_blank"&gt;Live Writer Source Code Format Plug-In&lt;/a&gt;. So far I am undecided whether I will continue to use this plug-in or continue my search for a better tool. Currently, the code is not formatted when I paste it into Live Writer, but that is minor. I also am not that happy with some of the styles, but that should be easy to fix myself.&lt;/p&gt;&lt;img src="http://detlefgrohs.com/aggbug.aspx?PostID=132" width="1" height="1"&gt;</description><category domain="http://detlefgrohs.com/blogs/wtf312/archive/category/1001.aspx">Blogging</category><category domain="http://detlefgrohs.com/blogs/wtf312/archive/category/1005.aspx">Coding</category></item><item><title>Another Code Post Test</title><link>http://detlefgrohs.com/blogs/wtf312/archive/2007/06/10/131.aspx</link><pubDate>Sun, 10 Jun 2007 14:49:04 GMT</pubDate><guid isPermaLink="false">f696011e-ecde-4552-b492-c119587d7670:131</guid><dc:creator>detlef</dc:creator><slash:comments>0</slash:comments><comments>http://detlefgrohs.com/blogs/wtf312/comments/131.aspx</comments><wfw:commentRss>http://detlefgrohs.com/blogs/wtf312/commentrss.aspx?PostID=131</wfw:commentRss><description>&lt;p&gt;Test 2&lt;/p&gt;&lt;pre class="csharpcode"&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; Form1()
        {
            InitializeComponent();
        }&lt;/pre&gt;
&lt;p&gt;Another Test&lt;/p&gt;&lt;img src="http://detlefgrohs.com/aggbug.aspx?PostID=131" width="1" height="1"&gt;</description><category domain="http://detlefgrohs.com/blogs/wtf312/archive/category/1001.aspx">Blogging</category><category domain="http://detlefgrohs.com/blogs/wtf312/archive/category/1005.aspx">Coding</category></item><item><title>Test Post With Code</title><link>http://detlefgrohs.com/blogs/wtf312/archive/2007/06/10/130.aspx</link><pubDate>Sun, 10 Jun 2007 14:43:12 GMT</pubDate><guid isPermaLink="false">f696011e-ecde-4552-b492-c119587d7670:130</guid><dc:creator>detlef</dc:creator><slash:comments>0</slash:comments><comments>http://detlefgrohs.com/blogs/wtf312/comments/130.aspx</comments><wfw:commentRss>http://detlefgrohs.com/blogs/wtf312/commentrss.aspx?PostID=130</wfw:commentRss><description>&lt;p&gt;Testing how a post with code will look:&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;pre class="csharpcode"&gt;CompilerParameters compiler_parameters = &lt;span class="kwrd"&gt;new&lt;/span&gt; CompilerParameters();
            compiler_parameters.CompilerOptions = &lt;span class="str"&gt;"/target:library"&lt;/span&gt;;
            compiler_parameters.GenerateExecutable = &lt;span class="kwrd"&gt;false&lt;/span&gt;;
            compiler_parameters.GenerateInMemory = &lt;span class="kwrd"&gt;true&lt;/span&gt;;
            compiler_parameters.IncludeDebugInformation = &lt;span class="kwrd"&gt;false&lt;/span&gt;;

            &lt;span class="rem"&gt;// add some basic references&lt;/span&gt;
            compiler_parameters.ReferencedAssemblies.Add(&lt;span class="str"&gt;"mscorlib.dll"&lt;/span&gt;);
            compiler_parameters.ReferencedAssemblies.Add(&lt;span class="str"&gt;"System.dll"&lt;/span&gt;);

            CompilerResults results = &lt;span class="kwrd"&gt;new&lt;/span&gt; CSharpCodeProvider().CompileAssemblyFromSource(compiler_parameters, source_code);

            &lt;span class="kwrd"&gt;if&lt;/span&gt; (results.Errors.HasErrors)
            {
                rtbOutput.Clear();
                &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (CompilerError error &lt;span class="kwrd"&gt;in&lt;/span&gt; results.Errors)
                {
                    rtbOutput.AppendText(&lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;"Line {0}, Column {1}: {2}\n"&lt;/span&gt;, 
                        error.Line - source_start_lines, error.Column, error.ErrorText));
                }
            }
            &lt;span class="kwrd"&gt;else&lt;/span&gt;
            {   &lt;span class="rem"&gt;//get a hold of the actual assembly that was generated&lt;/span&gt;
                Assembly generated_assembly = results.CompiledAssembly;

                Module module = generated_assembly.GetModules()[0];
                Type type = module.GetTypes()[0];

                System.IO.StringWriter string_writer = &lt;span class="kwrd"&gt;new&lt;/span&gt; System.IO.StringWriter();
                &lt;span class="kwrd"&gt;object&lt;/span&gt;[] parameters = { string_writer };

                MethodInfo method_info = type.GetMethod(&lt;span class="str"&gt;"main"&lt;/span&gt;);
                method_info.Invoke(&lt;span class="kwrd"&gt;null&lt;/span&gt;, parameters);

                rtbOutput.Clear();
                rtbOutput.AppendText(string_writer.ToString());
            }&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Looks fine in Live Writer. Now to see what it actually looks like in CS.&lt;/p&gt;&lt;img src="http://detlefgrohs.com/aggbug.aspx?PostID=130" width="1" height="1"&gt;</description><category domain="http://detlefgrohs.com/blogs/wtf312/archive/category/1001.aspx">Blogging</category><category domain="http://detlefgrohs.com/blogs/wtf312/archive/category/1005.aspx">Coding</category></item><item><title>Signs of a Crappy Programmer</title><link>http://detlefgrohs.com/blogs/wtf312/archive/2006/05/17/37.aspx</link><pubDate>Wed, 17 May 2006 15:05:00 GMT</pubDate><guid isPermaLink="false">f696011e-ecde-4552-b492-c119587d7670:37</guid><dc:creator>detlef</dc:creator><slash:comments>0</slash:comments><comments>http://detlefgrohs.com/blogs/wtf312/comments/37.aspx</comments><wfw:commentRss>http://detlefgrohs.com/blogs/wtf312/commentrss.aspx?PostID=37</wfw:commentRss><description>&lt;P&gt;Damien Katz has a great post that details the &lt;A href="http://damienkatz.net/2006/05/signs_youre_a_c.html"&gt;Signs You're a Crappy Programmer (and don't know it)&lt;/A&gt;. I know I have been guilty of some of these over my career, but growth is recognizing a weakness and overcoming it.&lt;/P&gt;&lt;img src="http://detlefgrohs.com/aggbug.aspx?PostID=37" width="1" height="1"&gt;</description><category domain="http://detlefgrohs.com/blogs/wtf312/archive/category/1005.aspx">Coding</category></item><item><title>Downloading File via FtpWebRequest in .NET 2.0</title><link>http://detlefgrohs.com/blogs/wtf312/archive/2006/04/13/7.aspx</link><pubDate>Thu, 13 Apr 2006 19:36:00 GMT</pubDate><guid isPermaLink="false">f696011e-ecde-4552-b492-c119587d7670:7</guid><dc:creator>detlef</dc:creator><slash:comments>0</slash:comments><comments>http://detlefgrohs.com/blogs/wtf312/comments/7.aspx</comments><wfw:commentRss>http://detlefgrohs.com/blogs/wtf312/commentrss.aspx?PostID=7</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=sans-serif&gt;I am working on my first Code Snippet for Visual Studio 2005 and I decided to use my downloading a file via FtpWebRequest as my first snippet. Here is what I reduced the code to for inclusion in the snippet, but this is the first time that I am really utilizing the using keyword and wonder if this is correct: &lt;/FONT&gt;&lt;/P&gt;
&lt;DIV style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: teal"&gt;FtpWebRequest&lt;/SPAN&gt; request = (&lt;SPAN style="COLOR: teal"&gt;FtpWebRequest&lt;/SPAN&gt;)&lt;SPAN style="COLOR: teal"&gt;FtpWebRequest&lt;/SPAN&gt;.Create(&lt;SPAN style="COLOR: maroon"&gt;@"ftp://ftp.somesite.com/somefile.txt"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;request.Credentials = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: teal"&gt;NetworkCredential&lt;/SPAN&gt;(&lt;SPAN style="COLOR: maroon"&gt;@"ftp_user"&lt;/SPAN&gt;, &lt;SPAN style="COLOR: maroon"&gt;@"ftp_password"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;request.Method = &lt;SPAN style="COLOR: teal"&gt;WebRequestMethods&lt;/SPAN&gt;.&lt;SPAN style="COLOR: teal"&gt;Ftp&lt;/SPAN&gt;.DownloadFile;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; (&lt;SPAN style="COLOR: teal"&gt;FtpWebResponse&lt;/SPAN&gt; response = (&lt;SPAN style="COLOR: teal"&gt;FtpWebResponse&lt;/SPAN&gt;)request.GetResponse())&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;{&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; (&lt;SPAN style="COLOR: teal"&gt;StreamReader&lt;/SPAN&gt; in_stream = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: teal"&gt;StreamReader&lt;/SPAN&gt;(response.GetResponseStream()))&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; (&lt;SPAN style="COLOR: teal"&gt;StreamWriter&lt;/SPAN&gt; out_stream = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: teal"&gt;StreamWriter&lt;/SPAN&gt;(&lt;SPAN style="COLOR: maroon"&gt;@"C:\localfile.txt"&lt;/SPAN&gt;, &lt;SPAN style="COLOR: blue"&gt;false&lt;/SPAN&gt;))&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&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;[] buffer = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;char&lt;/SPAN&gt;[1024];&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;while&lt;/SPAN&gt; (!in_stream.EndOfStream)&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&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; &lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt; bytes_read = in_stream.Read(buffer, 0, buffer.Length);&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&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; out_stream.Write(buffer, 0, bytes_read);&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;}&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;FONT face=sans-serif&gt;My question is, do I need to call the Close methods on the Response and Stream objects on lines 17, 18 and 19 or does the Dispose call handle this? Will post the snippet file once I have cleaned this up some more.&lt;/FONT&gt; &lt;/P&gt;&lt;img src="http://detlefgrohs.com/aggbug.aspx?PostID=7" width="1" height="1"&gt;</description><category domain="http://detlefgrohs.com/blogs/wtf312/archive/category/1005.aspx">Coding</category></item></channel></rss>