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

<channel>
	<title>John Nolan</title>
	<atom:link href="http://www.nolanscafe.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nolanscafe.co.uk</link>
	<description>scraps of code and info I pick up on my travels</description>
	<lastBuildDate>Tue, 30 Jun 2009 19:57:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Access control in masterpage from content page</title>
		<link>http://www.nolanscafe.co.uk/2009/06/30/access-control-in-masterpage-from-content-page/</link>
		<comments>http://www.nolanscafe.co.uk/2009/06/30/access-control-in-masterpage-from-content-page/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 16:01:33 +0000</pubDate>
		<dc:creator>Johnboy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.nolanscafe.co.uk/?p=47</guid>
		<description><![CDATA[Here is a nice easy one, if you have a control in your .master file that you need to access from your content page you can do the following to manipulate that control.
&#160;
// Create a new object that relates to your .master file control and call the FindControl function to return its properties
Xml xMasterHeaderXML = [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a nice easy one, if you have a control in your .master file that you need to access from your content page you can do the following to manipulate that control.</p>
<pre class="csharp">&nbsp;
<span style="color: #008080; font-style: italic;">// Create a new object that relates to your .master file control and call the FindControl function to return its properties</span>
Xml xMasterHeaderXML = <span style="color: #000000;">&#40;</span>Xml<span style="color: #000000;">&#41;</span>Master.<span style="color: #0000FF;">FindControl</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;xmlHeader&quot;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #008080; font-style: italic;">// Do a basic is null check to see if hte control is there or not</span>
<span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>xMasterHeaderXML != <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
     <span style="color: #008080; font-style: italic;">// Set whatever properties and values you need.</span>
     xMasterHeaderXML.<span style="color: #0000FF;">DocumentContent</span> = <span style="color: #808080;">&quot;&lt;root&gt;&lt;/root&gt;&quot;</span>;
     xMasterHeaderXML.<span style="color: #0000FF;">TransformSource</span> = <span style="color: #808080;">&quot;xsl/header.xsl&quot;</span>;
<span style="color: #000000;">&#125;</span>
&nbsp;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.nolanscafe.co.uk/2009/06/30/access-control-in-masterpage-from-content-page/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>C# Xml Manipulation: Copy Node</title>
		<link>http://www.nolanscafe.co.uk/2009/06/30/c-xml-manipulation-copy-node/</link>
		<comments>http://www.nolanscafe.co.uk/2009/06/30/c-xml-manipulation-copy-node/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 15:49:13 +0000</pubDate>
		<dc:creator>Johnboy</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[XSL]]></category>

		<guid isPermaLink="false">http://www.nolanscafe.co.uk/?p=48</guid>
		<description><![CDATA[Just loop through your xml structure using xPath, create a new node object, set the innertext property to value of the node to copy and then insert the value at the end of the current node set.
&#160;
XmlDocument xdocLocalFile = new XmlDocument&#40;&#41;;
&#160;
xdocLocalFile.Load&#40;&#34;MyXmlFile.xml&#34;&#41;;
&#160;
foreach &#40;XmlNode xNodeCopy in
          xdocLocalFile.SelectNodes&#40;&#34;/root/phunk&#34;&#41;&#41;
&#123;
  [...]]]></description>
			<content:encoded><![CDATA[<p>Just loop through your xml structure using xPath, create a new node object, set the innertext property to value of the node to copy and then insert the value at the end of the current node set.</p>
<pre class="csharp">&nbsp;
XmlDocument xdocLocalFile = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> XmlDocument<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
xdocLocalFile.<span style="color: #0000FF;">Load</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;MyXmlFile.xml&quot;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #0600FF;">foreach</span> <span style="color: #000000;">&#40;</span>XmlNode xNodeCopy <span style="color: #0600FF;">in</span>
          xdocLocalFile.<span style="color: #0000FF;">SelectNodes</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;/root/phunk&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
     XmlNode xNodeNew =
     xdocLocalFile.<span style="color: #0000FF;">CreateNode</span><span style="color: #000000;">&#40;</span>XmlNodeType.<span style="color: #0000FF;">Element</span>, <span style="color: #808080;">&quot;NewNodeName&quot;</span>, <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>;
&nbsp;
     xNodeNew.<span style="color: #0000FF;">InnerText</span> =
     xNodeCopy.<span style="color: #0000FF;">SelectSingleNode</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;CurrentNodeName&quot;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">FirstChild</span>.<span style="color: #0000FF;">Value</span>;
&nbsp;
     xNodeCopy.<span style="color: #0000FF;">InsertAfter</span><span style="color: #000000;">&#40;</span>xNodeNew, xNodeCopy.<span style="color: #0000FF;">LastChild</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span>
&nbsp;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.nolanscafe.co.uk/2009/06/30/c-xml-manipulation-copy-node/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# Xml Manipulation: Replace InnerText of Node</title>
		<link>http://www.nolanscafe.co.uk/2009/06/30/c-xml-manipulation-replace-innertext-of-node/</link>
		<comments>http://www.nolanscafe.co.uk/2009/06/30/c-xml-manipulation-replace-innertext-of-node/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 15:45:36 +0000</pubDate>
		<dc:creator>Johnboy</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[XSL]]></category>

		<guid isPermaLink="false">http://www.nolanscafe.co.uk/?p=58</guid>
		<description><![CDATA[Just loop through your xml structure using xPath as usual then call the InnerText property to set the new value.
&#160;
XmlDocument xdocLocalFile = new XmlDocument&#40;&#41;;
&#160;
xdocLocalFile.Load&#40;&#34;MyXmlFile.xml&#34;&#41;;
&#160;
foreach &#40;XmlNode xNodeReplace in
           xdocLocalFile.SelectNodes&#40;&#34;root/phunk&#34;&#41;&#41;
&#123;
           xNodeReplace.FirstChild.InnerText = &#34;My new Value&#34;;
&#125;
&#160;
]]></description>
			<content:encoded><![CDATA[<p>Just loop through your xml structure using xPath as usual then call the InnerText property to set the new value.</p>
<pre class="csharp">&nbsp;
XmlDocument xdocLocalFile = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> XmlDocument<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
xdocLocalFile.<span style="color: #0000FF;">Load</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;MyXmlFile.xml&quot;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #0600FF;">foreach</span> <span style="color: #000000;">&#40;</span>XmlNode xNodeReplace <span style="color: #0600FF;">in</span>
           xdocLocalFile.<span style="color: #0000FF;">SelectNodes</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;root/phunk&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
           xNodeReplace.<span style="color: #0000FF;">FirstChild</span>.<span style="color: #0000FF;">InnerText</span> = <span style="color: #808080;">&quot;My new Value&quot;</span>;
<span style="color: #000000;">&#125;</span>
&nbsp;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.nolanscafe.co.uk/2009/06/30/c-xml-manipulation-replace-innertext-of-node/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# Xml Manipulation: Remove Node</title>
		<link>http://www.nolanscafe.co.uk/2009/06/30/c-xml-manipulation-remove-node/</link>
		<comments>http://www.nolanscafe.co.uk/2009/06/30/c-xml-manipulation-remove-node/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 15:45:02 +0000</pubDate>
		<dc:creator>Johnboy</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[XSL]]></category>

		<guid isPermaLink="false">http://www.nolanscafe.co.uk/?p=53</guid>
		<description><![CDATA[To remove a node from an xml document just loop through all the nodes using xPath and then call the RemoveChild function like below.
&#160;
XmlDocument xdocLocalFile = new XmlDocument&#40;&#41;;
&#160;
xdocLocalFile.Load&#40;&#34;MyXmlFile.xml&#34;&#41;;
&#160;
foreach &#40;XmlNode xNodeReplace in
     xdocLocalFile.SelectNodes&#40;&#34;root/phunk/firstname&#34;&#41;&#41;
&#123;
     xNodeReplace.ParentNode.ParentNode.RemoveChild&#40;xNodeReplace.ParentNode&#41;;
&#125;
&#160;
]]></description>
			<content:encoded><![CDATA[<p>To remove a node from an xml document just loop through all the nodes using xPath and then call the RemoveChild function like below.</p>
<pre class="csharp">&nbsp;
XmlDocument xdocLocalFile = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> XmlDocument<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
xdocLocalFile.<span style="color: #0000FF;">Load</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;MyXmlFile.xml&quot;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #0600FF;">foreach</span> <span style="color: #000000;">&#40;</span>XmlNode xNodeReplace <span style="color: #0600FF;">in</span>
     xdocLocalFile.<span style="color: #0000FF;">SelectNodes</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;root/phunk/firstname&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
     xNodeReplace.<span style="color: #0000FF;">ParentNode</span>.<span style="color: #0000FF;">ParentNode</span>.<span style="color: #0000FF;">RemoveChild</span><span style="color: #000000;">&#40;</span>xNodeReplace.<span style="color: #0000FF;">ParentNode</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span>
&nbsp;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.nolanscafe.co.uk/2009/06/30/c-xml-manipulation-remove-node/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# Xml Manipulation: Create Node</title>
		<link>http://www.nolanscafe.co.uk/2009/06/30/c-xml-manipulation-create-node/</link>
		<comments>http://www.nolanscafe.co.uk/2009/06/30/c-xml-manipulation-create-node/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 15:44:33 +0000</pubDate>
		<dc:creator>Johnboy</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[XSL]]></category>

		<guid isPermaLink="false">http://www.nolanscafe.co.uk/?p=55</guid>
		<description><![CDATA[First loop through your nodes and for each one create a new XmlNode giving the name of the new node and then supplying the inner text to it. Then just add it to the end of the nodes in its parent.
&#160;
XmlDocument xdocLocalFile = new XmlDocument&#40;&#41;;
&#160;
xdocLocalFile.Load&#40;&#34;MyXmlFile.xml&#34;&#41;;
&#160;
foreach &#40;XmlNode xNodeReplace in
        [...]]]></description>
			<content:encoded><![CDATA[<p>First loop through your nodes and for each one create a new XmlNode giving the name of the new node and then supplying the inner text to it. Then just add it to the end of the nodes in its parent.</p>
<pre class="csharp">&nbsp;
XmlDocument xdocLocalFile = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> XmlDocument<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
xdocLocalFile.<span style="color: #0000FF;">Load</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;MyXmlFile.xml&quot;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #0600FF;">foreach</span> <span style="color: #000000;">&#40;</span>XmlNode xNodeReplace <span style="color: #0600FF;">in</span>
          xdocLocalFile.<span style="color: #0000FF;">SelectNodes</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;root/phunk&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	XmlNode xNodeNew =
        xdocLocalFile.<span style="color: #0000FF;">CreateNode</span><span style="color: #000000;">&#40;</span>XmlNodeType.<span style="color: #0000FF;">Element</span>, <span style="color: #808080;">&quot;NewColumnName&quot;</span>, <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>;
	xNodeNew.<span style="color: #0000FF;">InnerText</span> = <span style="color: #808080;">&quot;Here is my new value&quot;</span>;
&nbsp;
	xNodeReplace.<span style="color: #0000FF;">InsertAfter</span><span style="color: #000000;">&#40;</span>xNodeNew, xNodeReplace.<span style="color: #0000FF;">LastChild</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span>
&nbsp;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.nolanscafe.co.uk/2009/06/30/c-xml-manipulation-create-node/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add a META tag to a head tag through C#</title>
		<link>http://www.nolanscafe.co.uk/2009/06/17/add-a-meta-tag-to-a-head-tag-through-c/</link>
		<comments>http://www.nolanscafe.co.uk/2009/06/17/add-a-meta-tag-to-a-head-tag-through-c/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 10:24:44 +0000</pubDate>
		<dc:creator>Johnboy</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://www.nolanscafe.co.uk/?p=41</guid>
		<description><![CDATA[Here is a nice one as well, how to add a meta data tag to your page header tag. This one below adds the nofollow malarky needed for those SEO boffins.
&#160;
HtmlMeta hmRobots = new HtmlMeta&#40;&#41;;
&#160;
// Get a reference to the page header element.
HtmlHead hhRobots = &#40;HtmlHead&#41;Page.Header;
&#160;
// Define an HTML &#60;meta&#62; element that is useful for [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a nice one as well, how to add a meta data tag to your page header tag. This one below adds the nofollow malarky needed for those SEO boffins.</p>
<pre class="csharp">&nbsp;
HtmlMeta hmRobots = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> HtmlMeta<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #008080; font-style: italic;">// Get a reference to the page header element.</span>
HtmlHead hhRobots = <span style="color: #000000;">&#40;</span>HtmlHead<span style="color: #000000;">&#41;</span>Page.<span style="color: #0000FF;">Header</span>;
&nbsp;
<span style="color: #008080; font-style: italic;">// Define an HTML &lt;meta&gt; element that is useful for search engines.</span>
hmRobots.<span style="color: #0000FF;">Name</span> = <span style="color: #808080;">&quot;robots&quot;</span>;
hmRobots.<span style="color: #0000FF;">Content</span> = <span style="color: #808080;">&quot;noindex,noarchive,follow&quot;</span>;
hhRobots.<span style="color: #0000FF;">Controls</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>hmRobots<span style="color: #000000;">&#41;</span>;
&nbsp;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.nolanscafe.co.uk/2009/06/17/add-a-meta-tag-to-a-head-tag-through-c/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Create a cookie and read it back in C#</title>
		<link>http://www.nolanscafe.co.uk/2009/06/17/create-a-cookie-and-read-it-back-in-c/</link>
		<comments>http://www.nolanscafe.co.uk/2009/06/17/create-a-cookie-and-read-it-back-in-c/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 09:31:51 +0000</pubDate>
		<dc:creator>Johnboy</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Freelance]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.nolanscafe.co.uk/?p=37</guid>
		<description><![CDATA[Been a bit bare at the mo, lots of dev work going on so thought I would fill it with a simple how to with Cookies.
To create a cookie on your site...
&#160;
// Lets check if it exists or not yet.
if &#40;Request.Cookies&#91;&#34;MySite_LastVisit&#34;&#93; == null&#41;
&#123;
&#160;
// Create new Cookie object to store users last visit to the site.
HttpCookie [...]]]></description>
			<content:encoded><![CDATA[<p>Been a bit bare at the mo, lots of dev work going on so thought I would fill it with a simple how to with Cookies.</p>
<p>To create a cookie on your site...</p>
<pre class="csharp">&nbsp;
<span style="color: #008080; font-style: italic;">// Lets check if it exists or not yet.</span>
<span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>Request.<span style="color: #0000FF;">Cookies</span><span style="color: #000000;">&#91;</span><span style="color: #808080;">&quot;MySite_LastVisit&quot;</span><span style="color: #000000;">&#93;</span> == <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
&nbsp;
<span style="color: #008080; font-style: italic;">// Create new Cookie object to store users last visit to the site.</span>
HttpCookie ckUserLastVisit = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> HttpCookie<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;MySite_LastVisit&quot;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #008080; font-style: italic;">// Get current date/time</span>
DateTime dtNow = DateTime.<span style="color: #0000FF;">Now</span>;
&nbsp;
<span style="color: #008080; font-style: italic;">// Set the cookie value.</span>
ckUserLastVisit.<span style="color: #0000FF;">Value</span> = dtNow.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #008080; font-style: italic;">// Set the cookie expiration date. We will say one day from now</span>
<span style="color: #008080; font-style: italic;">// but you could say as long as you want.</span>
ckUserLastVisit.<span style="color: #0000FF;">Expires</span> = dtNow.<span style="color: #0000FF;">AddDays</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #008080; font-style: italic;">// Add the cookie.</span>
Response.<span style="color: #0000FF;">Cookies</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>ckUserLastVisit<span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #000000;">&#125;</span></pre>
<p>So that is it created. Lets see how to read that information back.</p>
<pre class="csharp">&nbsp;
<span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>Request.<span style="color: #0000FF;">Cookies</span><span style="color: #000000;">&#91;</span><span style="color: #808080;">&quot;MySite_LastVisit&quot;</span><span style="color: #000000;">&#93;</span> == <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
<span style="color: #008080; font-style: italic;">// Just assign our value to a new string and then do what we want with it.</span>
<span style="color: #FF0000;">String</span> sLastVisitDate = Request.<span style="color: #0000FF;">Cookies</span><span style="color: #000000;">&#91;</span><span style="color: #808080;">&quot;MySite_LastVisit&quot;</span><span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">Value</span>;
<span style="color: #000000;">&#125;</span>
&nbsp;</pre>
<p>That should be it, nice and simple.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nolanscafe.co.uk/2009/06/17/create-a-cookie-and-read-it-back-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Convert bytes to Megabytes in C#</title>
		<link>http://www.nolanscafe.co.uk/2009/05/20/convert-bytes-to-megabytes-in-c/</link>
		<comments>http://www.nolanscafe.co.uk/2009/05/20/convert-bytes-to-megabytes-in-c/#comments</comments>
		<pubDate>Wed, 20 May 2009 15:37:42 +0000</pubDate>
		<dc:creator>Johnboy</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://www.nolanscafe.co.uk/?p=32</guid>
		<description><![CDATA[Here is a nice little function to quickly get the size of a file on your server. Great for displaying the size of images in a gallery for example.
private String fnGetImageSize&#40;String sFilePath&#41;
&#123;
	try
	&#123;
		System.IO.FileInfo fi = new System.IO.FileInfo&#40;sFilePath&#41;;
		return ConvertBytesToMegabytes&#40;fi.Length&#41;.ToString&#40;&#34;0.00&#34;&#41;;
	&#125;
	catch
	&#123;
		return &#34;0&#34;;
	&#125;
&#125;
&#160;
static double ConvertBytesToMegabytes&#40;long b&#41;
&#123;
	return &#40;b / 1024f&#41; / 1024f;
&#125;
]]></description>
			<content:encoded><![CDATA[<p>Here is a nice little function to quickly get the size of a file on your server. Great for displaying the size of images in a gallery for example.</p>
<pre class="csharp"><span style="color: #0600FF;">private</span> <span style="color: #FF0000;">String</span> fnGetImageSize<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">String</span> sFilePath<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #0600FF;">try</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #000000;">System</span>.<span style="color: #0000FF;">IO</span>.<span style="color: #0000FF;">FileInfo</span> fi = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">IO</span>.<span style="color: #0000FF;">FileInfo</span><span style="color: #000000;">&#40;</span>sFilePath<span style="color: #000000;">&#41;</span>;
		<span style="color: #0600FF;">return</span> ConvertBytesToMegabytes<span style="color: #000000;">&#40;</span>fi.<span style="color: #0000FF;">Length</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;0.00&quot;</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0600FF;">catch</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0600FF;">return</span> <span style="color: #808080;">&quot;0&quot;</span>;
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0600FF;">static</span> <span style="color: #FF0000;">double</span> ConvertBytesToMegabytes<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">long</span> b<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #0600FF;">return</span> <span style="color: #000000;">&#40;</span>b / 1024f<span style="color: #000000;">&#41;</span> / 1024f;
<span style="color: #000000;">&#125;</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.nolanscafe.co.uk/2009/05/20/convert-bytes-to-megabytes-in-c/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Adding twitter feeds to a C# website using Yedda</title>
		<link>http://www.nolanscafe.co.uk/2009/04/07/adding-twitter-feeds-to-a-c-website-using-yedda/</link>
		<comments>http://www.nolanscafe.co.uk/2009/04/07/adding-twitter-feeds-to-a-c-website-using-yedda/#comments</comments>
		<pubDate>Tue, 07 Apr 2009 21:10:02 +0000</pubDate>
		<dc:creator>Johnboy</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.nolanscafe.co.uk/?p=17</guid>
		<description><![CDATA[I found a great library today for importing twitter feeds to your application using Yedda. http://devblog.yedda.com. Below is a small sample of the basic use.
To install simply download the source, stick the Twitter.cs file in your bin directory and do the following on yoru page load. Then manipulate the returned XML as you wish in [...]]]></description>
			<content:encoded><![CDATA[<p>I found a great library today for importing twitter feeds to your application using Yedda. <a href="http://devblog.yedda.com">http://devblog.yedda.com</a>. Below is a small sample of the basic use.</p>
<p>To install simply download the source, stick the Twitter.cs file in your bin directory and do the following on yoru page load. Then manipulate the returned XML as you wish in your XSL.</p>
<p>C# Code</p>
<pre class="csharp"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Twitter twitNews = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Twitter<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">XmlDocument xmlTwitterDoc =</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">twitNews.<span style="color: #0000FF;">GetUserTimelineAsXML</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;username&quot;</span>, <span style="color: #808080;">&quot;password&quot;</span>, <span style="color: #808080;">&quot;johnboynolan&quot;</span>,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Twitter.<span style="color: #0000FF;">OutputFormatType</span>.<span style="color: #0000FF;">XML</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>Simple as that!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nolanscafe.co.uk/2009/04/07/adding-twitter-feeds-to-a-c-website-using-yedda/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Limit the amount of characters in xsl select string</title>
		<link>http://www.nolanscafe.co.uk/2009/04/07/limit-the-amount-of-characters-in-xsl-select-string/</link>
		<comments>http://www.nolanscafe.co.uk/2009/04/07/limit-the-amount-of-characters-in-xsl-select-string/#comments</comments>
		<pubDate>Tue, 07 Apr 2009 21:02:14 +0000</pubDate>
		<dc:creator>Johnboy</dc:creator>
				<category><![CDATA[XSL]]></category>

		<guid isPermaLink="false">http://www.nolanscafe.co.uk/?p=14</guid>
		<description><![CDATA[Okay, a nice simple one that I found today, might be useful. If you ever have to display content on your site and need to limit the amount of characters in it, such as a summary, then you can use something like the following to display what you need. This also adds '...' after the [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, a nice simple one that I found today, might be useful. If you ever have to display content on your site and need to limit the amount of characters in it, such as a summary, then you can use something like the following to display what you need. This also adds '...' after the final characters.</p>
<p>Great if you are not in control of the data source such as twitter feeds.</p>
<pre class="xml">&nbsp;
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;concat(substring(text, 1, 100), '...')&quot;</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>
&nbsp;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.nolanscafe.co.uk/2009/04/07/limit-the-amount-of-characters-in-xsl-select-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
