<?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>Phil Leggetter - Software Consultant &#187; C#</title>
	<atom:link href="http://www.leggetter.co.uk/tag/c/feed" rel="self" type="application/rss+xml" />
	<link>http://www.leggetter.co.uk</link>
	<description>Real-time web and social media software consultant</description>
	<lastBuildDate>Thu, 09 Sep 2010 14:17:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Basic Authentication against the Superfeedr HTTP PubSubHubbub API using a .NET HttpWebRequest</title>
		<link>http://www.leggetter.co.uk/2010/07/04/basic-authentication-against-the-superfeedr-http-pubsubhubbub-api-using-a-net-httpwebrequest.html</link>
		<comments>http://www.leggetter.co.uk/2010/07/04/basic-authentication-against-the-superfeedr-http-pubsubhubbub-api-using-a-net-httpwebrequest.html#comments</comments>
		<pubDate>Sun, 04 Jul 2010 09:58:00 +0000</pubDate>
		<dc:creator>Phil Leggetter</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[pubsubhubbub]]></category>
		<category><![CDATA[Superfeedr]]></category>

		<guid isPermaLink="false">http://blog.kwwika.com/basic-authentication-against-the-superfeedr-h</guid>
		<description><![CDATA[        
	It would appear that setting the Credentials [...]


Related posts:<ol><li><a href='http://www.leggetter.co.uk/2008/10/24/how-to-make-a-cross-domain-web-request-with-silverlight-2.html' rel='bookmark' title='Permanent Link: How to make a cross domain web request with SilverLight 2'>How to make a cross domain web request with SilverLight 2</a></li>
<li><a href='http://www.leggetter.co.uk/2010/08/10/kwwika-superfeedr-real-time-demo-available-2.html' rel='bookmark' title='Permanent Link: Kwwika-Superfeedr real-time demo available'>Kwwika-Superfeedr real-time demo available</a></li>
<li><a href='http://www.leggetter.co.uk/2009/10/30/using-fiddler-to-trick-silverlight-into-allowing-a-crossdomain-web-request.html' rel='bookmark' title='Permanent Link: Using Fiddler to trick Silverlight into allowing a crossdomain Web Request'>Using Fiddler to trick Silverlight into allowing a crossdomain Web Request</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>It would appear that setting the Credentials property of a HttpWebRequest still leads to authentication failure against the <a  href="http://superfeedr.com/documentation#pubsubhubbub">Superfeedr HTTP PubSubHubbub API</a>. This might be because the way the HttpWebRequest works is that it first waits to be challenged for credentials via a 401 (not authorized) and then replies with the authentication (<a  href="http://www.west-wind.com/weblog/posts/243915.aspx">more info include PreAuthenticate here</a>).</p>
<p>So, this doesn&#8217;t work:</p>
<pre class="brush: csharp;">
string username = &quot;username&quot;;
string password = &quot;password&quot;;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(&quot;url-here&quot;);
request.Credentials = new NetworkCredential(username, password);
</pre>
<p>To work around this you need to force the authentication to be sent. I found the details of how to do this in a blog post by Ian Dykes here:</p>
<p><a  href="http://devproj20.blogspot.com/2008/02/assigning-basic-authorization-http.html">http://devproj20.blogspot.com/2008/02/assigning-basic-authorization-http.html</a></p>
<p>But for fullness here&#8217;s the code:</p>
<pre class="brush: csharp;">
string username = &quot;username&quot;;
string password = &quot;password&quot;;
byte[] authBytes = Encoding.UTF8.GetBytes(username + &quot;:&quot; + password.ToCharArray());
request.Headers[&quot;Authorization&quot;] = &quot;Basic &quot; + Convert.ToBase64String(authBytes);
</pre>
<p><a  href="http://blog.kwwika.com/basic-authentication-against-the-superfeedr-h">Permalink</a> </p>
<p>	| <a  href="http://blog.kwwika.com/basic-authentication-against-the-superfeedr-h#comment">Leave a comment&nbsp;&nbsp;&raquo;</a></p><!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em> </em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.leggetter.co.uk%2F2010%2F07%2F04%2Fbasic-authentication-against-the-superfeedr-http-pubsubhubbub-api-using-a-net-httpwebrequest.html&amp;title=Basic+Authentication+against+the+Superfeedr+HTTP+PubSubHubbub+API+using+a+.NET+HttpWebRequest" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.leggetter.co.uk%2F2010%2F07%2F04%2Fbasic-authentication-against-the-superfeedr-http-pubsubhubbub-api-using-a-net-httpwebrequest.html&amp;title=Basic+Authentication+against+the+Superfeedr+HTTP+PubSubHubbub+API+using+a+.NET+HttpWebRequest" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dotnetkicks.com/kick/?url=http%3A%2F%2Fwww.leggetter.co.uk%2F2010%2F07%2F04%2Fbasic-authentication-against-the-superfeedr-http-pubsubhubbub-api-using-a-net-httpwebrequest.html&amp;title=Basic+Authentication+against+the+Superfeedr+HTTP+PubSubHubbub+API+using+a+.NET+HttpWebRequest" rel="nofollow" title="Add to&nbsp;DotNetKicks"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/dotnetkicks.png" title="Add to&nbsp;DotNetKicks" alt="Add to&nbsp;DotNetKicks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.leggetter.co.uk%2F2010%2F07%2F04%2Fbasic-authentication-against-the-superfeedr-http-pubsubhubbub-api-using-a-net-httpwebrequest.html" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.leggetter.co.uk%2F2010%2F07%2F04%2Fbasic-authentication-against-the-superfeedr-http-pubsubhubbub-api-using-a-net-httpwebrequest.html&amp;title=Basic+Authentication+against+the+Superfeedr+HTTP+PubSubHubbub+API+using+a+.NET+HttpWebRequest" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.leggetter.co.uk%2F2010%2F07%2F04%2Fbasic-authentication-against-the-superfeedr-http-pubsubhubbub-api-using-a-net-httpwebrequest.html&amp;title=Basic+Authentication+against+the+Superfeedr+HTTP+PubSubHubbub+API+using+a+.NET+HttpWebRequest" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.leggetter.co.uk%2F2010%2F07%2F04%2Fbasic-authentication-against-the-superfeedr-http-pubsubhubbub-api-using-a-net-httpwebrequest.html&amp;title=Basic+Authentication+against+the+Superfeedr+HTTP+PubSubHubbub+API+using+a+.NET+HttpWebRequest" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.leggetter.co.uk%2F2010%2F07%2F04%2Fbasic-authentication-against-the-superfeedr-http-pubsubhubbub-api-using-a-net-httpwebrequest.html" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Basic+Authentication+against+the+Superfeedr+HTTP+PubSubHubbub+API+using+a+.NET+HttpWebRequest+@+http%3A%2F%2Fwww.leggetter.co.uk%2F2010%2F07%2F04%2Fbasic-authentication-against-the-superfeedr-http-pubsubhubbub-api-using-a-net-httpwebrequest.html" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fwww.leggetter.co.uk%2F2010%2F07%2F04%2Fbasic-authentication-against-the-superfeedr-http-pubsubhubbub-api-using-a-net-httpwebrequest.html&amp;t=Basic+Authentication+against+the+Superfeedr+HTTP+PubSubHubbub+API+using+a+.NET+HttpWebRequest" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->


<p>Related posts:<ol><li><a href='http://www.leggetter.co.uk/2008/10/24/how-to-make-a-cross-domain-web-request-with-silverlight-2.html' rel='bookmark' title='Permanent Link: How to make a cross domain web request with SilverLight 2'>How to make a cross domain web request with SilverLight 2</a></li>
<li><a href='http://www.leggetter.co.uk/2010/08/10/kwwika-superfeedr-real-time-demo-available-2.html' rel='bookmark' title='Permanent Link: Kwwika-Superfeedr real-time demo available'>Kwwika-Superfeedr real-time demo available</a></li>
<li><a href='http://www.leggetter.co.uk/2009/10/30/using-fiddler-to-trick-silverlight-into-allowing-a-crossdomain-web-request.html' rel='bookmark' title='Permanent Link: Using Fiddler to trick Silverlight into allowing a crossdomain Web Request'>Using Fiddler to trick Silverlight into allowing a crossdomain Web Request</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.leggetter.co.uk/2010/07/04/basic-authentication-against-the-superfeedr-http-pubsubhubbub-api-using-a-net-httpwebrequest.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How I approach problem solving in code?</title>
		<link>http://www.leggetter.co.uk/2009/10/23/how-i-approach-problem-solving-in-code.html</link>
		<comments>http://www.leggetter.co.uk/2009/10/23/how-i-approach-problem-solving-in-code.html#comments</comments>
		<pubDate>Fri, 23 Oct 2009 17:44:57 +0000</pubDate>
		<dc:creator>Phil Leggetter</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Agile]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[problem solving]]></category>

		<guid isPermaLink="false">http://www.leggetter.co.uk/?p=382</guid>
		<description><![CDATA[Recently I was posed the following question:
Write a p [...]


Related posts:<ol><li><a href='http://www.leggetter.co.uk/2008/12/10/problem-solving-lessons-relearnt.html' rel='bookmark' title='Permanent Link: Problem solving lessons relearnt'>Problem solving lessons relearnt</a></li>
<li><a href='http://www.leggetter.co.uk/2010/07/04/basic-authentication-against-the-superfeedr-http-pubsubhubbub-api-using-a-net-httpwebrequest.html' rel='bookmark' title='Permanent Link: Basic Authentication against the Superfeedr HTTP PubSubHubbub API using a .NET HttpWebRequest'>Basic Authentication against the Superfeedr HTTP PubSubHubbub API using a .NET HttpWebRequest</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Recently I was posed the following question:</p>
<blockquote><p>Write a piece of code that prints all odd integer numbers between 1 and 99</p></blockquote>
<p>This really isn&#8217;t a difficult question but it still requires some thought. When I&#8217;m posed with any question I like to break things down into their constituent parts.</p>
<p>Here&#8217;s the process I went through:</p>
<p>Okay, so I&#8217;ll define two variables for a start and end value and there&#8217;s going to have to be a loop.</p>
<pre class="brush: csharp;">int startValue = 1;
int endValue = 99;
for(int i = startValue;
     i &amp;lt;= endValue;
     i++)
{
   // work out if &quot;i&quot; is an odd number
}</pre>
<p>Now, for the odd number detection. And&#8230; after a few umms and errrs &#8230; I&#8217;m going to have to mod 2 (<code>%2</code>) the current value of <code>i</code> to work out if the value is odd. More &#8230; umms and errs. Okay, I&#8217;ve finally worked out that if something mod 2 is not equal to 0 it&#8217;s clearly an odd number. This took me longer than it should have but never mind. Once I&#8217;ve detected if <code>i</code> is an odd number I&#8217;ll then put the odd number into a list for use later.</p>
<pre class="brush: csharp;">
int startValue = 1;
int endValue = 99;
IList&lt;int&gt; oddValues = new List&amp;lt;int&amp;gt;();
for(int i = startValue;
     i &amp;lt;= endValue;
     i++)
{
   if(i%2 != 0)
   {
      oddValues.Add(i);
   }
}
</pre>
<p>Those of you that are good at these little puzzles, or just think this is way too easy, might already be screaming at me about one of the following:</p>
<ul>
<li>Why are you using a <code>IList<int></code>, why don&#8217;t you just print the value?</li>
<li>Odd numbers are always 2 apart so why aren&#8217;t you just increment <code>i</code> by 2 using <code>i+=2</code>?</li>
</ul>
<p><span id="more-382"></span><br />
I admit it,  I missed the second point and that is a bit silly of me. However, what I have starting doing is <a  title="separation of concerns" href="http://en.wikipedia.org/wiki/Separation_of_concerns">separating the concerns</a> of the piece of code. The code does two things; it detects the odd number and it prints the odd numbers. Those are two very distinct things. So, my code now looks like this:</p>
<pre class="brush: csharp;">
int startValue = 1;
int endValue = 99;
IList&lt;int&gt; oddNumbers = new List&amp;lt;int&amp;gt;();
for(int i = startValue;
     i &amp;lt;= endValue;
     i++)
{
   if(i%2 != 0)
   {
      oddNumbers.Add(i);
   }
}

string oddNumbersList = string.Join(&quot;,&quot;, oddNumbers.ToArray());
Console.WriteLine(oddNumbersList );
</pre>
<p>I&#8217;m now going to refactor this further so I&#8217;ll put the two different pieces of functionality into different methods. I&#8217;ll rename the <code>i</code>, <code>startValue</code> and <code>endValue</code> variables to be something a bit more useful; say <code>numberToCheck</code>, <code>startNumber</code> and <code>endNumber</code>. I&#8217;ll also create another helper for the odd number checking named <code>IsOddNumber</code>:</p>
<pre class="brush: csharp;">
IList&lt;int&gt; GetOddNumbersBetween(int startNumber, int endNumber)
{
   IList oddValues = new List&amp;lt;int&amp;gt;();
   for(int numberToCheck = startNumber;
        numberToCheck &amp;lt;= endNumber;
        numberToCheck++)
   {
      if(IsOddNumber(numberToCheck) == true)
      {
         oddValues.Add(numberToChecki);
      }
   }
   return oddValues;
}

bool IsOddNumber(int number)
{
   return (number % 2 == 1);
}

void PrintOddNumbersBetween(int startNumber, int endNumber)
{
   IList&lt;int&gt; oddNumbers = GetOddNumbersBetween(startNumber, endNumber);
   string oddNumbersList = string.Join(&quot;,&quot;, oddNumbers.ToArray());
   Console.WriteLine(oddNumbersList);
}
</pre>
<p>Let&#8217;s say I then notice the second point you&#8217;ve been screaming at me about (Odd numbers are always 2 apart so why aren&#8217;t you just increment i by 2 using i+=2) that I mentioned above? In practice I should notice this sort of thing either when I give the code a complete review, or one of my peers spots it. When I see this problem I decide to update the <code>for</code> loop, as noted, and I then see that I possibly don&#8217;t need the <code>if(IsOddNumber(i) == true)</code> statement. Although it would pain me to do this, since it&#8217;s a lovely little method, I would need to consider deleting it. But then it strikes me, I&#8217;m no longer just solving the &#8220;odd numbers between 1 and 99 problem&#8221; so I can&#8217;t just assume that the <code>startNumber</code> is going to be an odd number. I need to make sure that it&#8217;s an odd number so I&#8217;ll create another small utility method for that called <code>EnsureOddNumber</code> which will check if the value passed is an odd number, and if not return the next odd number (I&#8217;d like to rethink the name of this method).</p>
<pre class="brush: csharp;">
IList&lt;int&gt; GetOddNumbersBetween(int startNumber, int endNumber)
{
   startNumber = EnsureOddNumber(startNumber);

   IList&lt;int&gt; oddValues = new List&amp;lt;int&amp;gt;();
   for(int numberToCheck = startNumber;
        numberToCheck &amp;lt;= endNumber;
        numberToCheck+=2)
   {
      oddValues.Add(numberToCheck);
   }
   return oddValues;
}

int EnsureOddNumber(int number)
{
   if( IsOddNumber(startNumber) == false )
   {
      startNumber++;
   }
   return startNumber;
}

bool IsOddNumber(int number)
{
   return (number % 2 == 1);
}

void PrintOddNumbersBetween(int startNumber, int endNumber)
{
   IList&lt;int&gt; oddNumbers = GetOddNumbersBetween(startNumber, endNumber);
   string oddNumbersList = string.Join(&quot;,&quot;, oddNumbers.ToArray());
   Console.WriteLine(oddNumbersList);
}
</pre>
<p>Now, when I look at this code I get a warm feeling because I feel that it solves the problem, it&#8217;s well engineered, the concerns are separated and the code is completely <a  href="http://en.wikipedia.org/wiki/Self-documenting">self documenting</a>.</p>
<p>There are a few comments that people may have here:</p>
<blockquote><p>The question asked specifically to print odd values between 1 and 99 and you&#8217;ve done more than was required.</p></blockquote>
<p>Although my answer does satisfy the original question have I over engineered things? The question does specifically ask us to print odd values between 1 and 99 so maybe I should have created a function that just satisfied that requirement.</p>
<pre class="brush: csharp;">
void PrintOddNumbersBetween1And99()
{
   for(int i = 1;
        i &amp;lt;= 99;
        i+=2)
   {
      Console.WriteLine(i + &quot; &quot;);
   }
}
</pre>
<p>And I&#8217;d have to admit that this very short piece of code exactly answers the question. But I&#8217;d also argue that there is very little chance of this code being reused. Don&#8217;t get me wrong, you definitely shouldn&#8217;t over engineer things but there should be some scope for <a  href="http://en.wikipedia.org/wiki/Code_reuse">code reuse</a>.</p>
<blockquote><p>For such a simple problem you&#8217;ve over engineered this.</p></blockquote>
<p>or</p>
<blockquote><p>There&#8217;s a better solutions that that&#8230; it&#8217;s not efficient</p></blockquote>
<p>Is creating four methods over engieering? Does my code require any comments to provide documentation? There may well be a more performant solution to this, but that&#8217;s not my point. My point is the way of approaching a question: the thought processes involved in understanding the problem and breaking it down to <a  href="http://en.wikipedia.org/wiki/Separation_of_concerns">separate concerns</a>, making it easy to read, <a  href="http://en.wikipedia.org/wiki/Code_reuse">reusable</a> and <a  href="http://en.wikipedia.org/wiki/Self-documenting">self documenting</a>. If the code that worked out the odd numbers is not efficient it could easily be changed in one place without impacting the interface, the other methods within the class, or the overall functionality.</p>
<p>Some people may jump to the simplest solution but I think the way i&#8217;ve described approaching and solving the problem demonstrates good practice. If I&#8217;m completely honest I would normally approach the development of something such as this by writing a test case first since I practice <a  href="http://en.wikipedia.org/wiki/Test-driven_development">TDD</a> but that can wait for another blog post.</p><!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em> </em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.leggetter.co.uk%2F2009%2F10%2F23%2Fhow-i-approach-problem-solving-in-code.html&amp;title=How+I+approach+problem+solving+in+code%3F" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.leggetter.co.uk%2F2009%2F10%2F23%2Fhow-i-approach-problem-solving-in-code.html&amp;title=How+I+approach+problem+solving+in+code%3F" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dotnetkicks.com/kick/?url=http%3A%2F%2Fwww.leggetter.co.uk%2F2009%2F10%2F23%2Fhow-i-approach-problem-solving-in-code.html&amp;title=How+I+approach+problem+solving+in+code%3F" rel="nofollow" title="Add to&nbsp;DotNetKicks"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/dotnetkicks.png" title="Add to&nbsp;DotNetKicks" alt="Add to&nbsp;DotNetKicks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.leggetter.co.uk%2F2009%2F10%2F23%2Fhow-i-approach-problem-solving-in-code.html" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.leggetter.co.uk%2F2009%2F10%2F23%2Fhow-i-approach-problem-solving-in-code.html&amp;title=How+I+approach+problem+solving+in+code%3F" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.leggetter.co.uk%2F2009%2F10%2F23%2Fhow-i-approach-problem-solving-in-code.html&amp;title=How+I+approach+problem+solving+in+code%3F" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.leggetter.co.uk%2F2009%2F10%2F23%2Fhow-i-approach-problem-solving-in-code.html&amp;title=How+I+approach+problem+solving+in+code%3F" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.leggetter.co.uk%2F2009%2F10%2F23%2Fhow-i-approach-problem-solving-in-code.html" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+How+I+approach+problem+solving+in+code%3F+@+http%3A%2F%2Fwww.leggetter.co.uk%2F2009%2F10%2F23%2Fhow-i-approach-problem-solving-in-code.html" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fwww.leggetter.co.uk%2F2009%2F10%2F23%2Fhow-i-approach-problem-solving-in-code.html&amp;t=How+I+approach+problem+solving+in+code%3F" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->


<p>Related posts:<ol><li><a href='http://www.leggetter.co.uk/2008/12/10/problem-solving-lessons-relearnt.html' rel='bookmark' title='Permanent Link: Problem solving lessons relearnt'>Problem solving lessons relearnt</a></li>
<li><a href='http://www.leggetter.co.uk/2010/07/04/basic-authentication-against-the-superfeedr-http-pubsubhubbub-api-using-a-net-httpwebrequest.html' rel='bookmark' title='Permanent Link: Basic Authentication against the Superfeedr HTTP PubSubHubbub API using a .NET HttpWebRequest'>Basic Authentication against the Superfeedr HTTP PubSubHubbub API using a .NET HttpWebRequest</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.leggetter.co.uk/2009/10/23/how-i-approach-problem-solving-in-code.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>How to make a cross domain web request with SilverLight 2</title>
		<link>http://www.leggetter.co.uk/2008/10/24/how-to-make-a-cross-domain-web-request-with-silverlight-2.html</link>
		<comments>http://www.leggetter.co.uk/2008/10/24/how-to-make-a-cross-domain-web-request-with-silverlight-2.html#comments</comments>
		<pubDate>Fri, 24 Oct 2008 12:16:18 +0000</pubDate>
		<dc:creator>Phil Leggetter</dc:creator>
				<category><![CDATA[thoughts]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[crossdomain]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://www.leggetter.co.uk/?p=60</guid>
		<description><![CDATA[To make a cross domain web request with SilverLight 2 r [...]


Related posts:<ol><li><a href='http://www.leggetter.co.uk/2009/10/30/using-fiddler-to-trick-silverlight-into-allowing-a-crossdomain-web-request.html' rel='bookmark' title='Permanent Link: Using Fiddler to trick Silverlight into allowing a crossdomain Web Request'>Using Fiddler to trick Silverlight into allowing a crossdomain Web Request</a></li>
<li><a href='http://www.leggetter.co.uk/2010/03/19/using-fiddler-to-help-develop-cross-domain-capable-javascript-web-applications.html' rel='bookmark' title='Permanent Link: Using Fiddler to help develop cross domain capable JavaScript web applications'>Using Fiddler to help develop cross domain capable JavaScript web applications</a></li>
<li><a href='http://www.leggetter.co.uk/2010/03/12/making-cross-domain-javascript-requests-using-xmlhttprequest-or-xdomainrequest.html' rel='bookmark' title='Permanent Link: Making cross domain JavaScript requests using XMLHttpRequest or XDomainRequest'>Making cross domain JavaScript requests using XMLHttpRequest or XDomainRequest</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>To make a cross domain web request with SilverLight 2 really isn&#8217;t that tough. I did have some problems with RC0 but I have no idea why. I just tried writing a little app to do this and it worked straight away.<br />
<span id="more-60"></span></p>
<p>Here&#8217;s the code. It&#8217;s obviously part of a full solution containing a Web Application and a SilverLight Application project. I&#8217;ve also <a  href="http://www.leggetter.co.uk/wp-content/uploads/2008/10/silverlightcrossdomainapplication.zip">uploaded it</a>.</p>
<h2>Useful Information:</h2>
<ul>
<li>You <strong>can not</strong> do a cross domain request over HTTPS.</li>
<li>You <strong>can</strong> do a cross domain request over HTTP.</li>
<li>To be able to make the cross domain request the server that you are making the request to needs to have either (requires clarification) <a  href="http://www.leggetter.co.uk/crossdomain.xml"> crossdomain.xml</a> and/or <a  href="http://www.leggetter.co.uk/clientaccesspolicy.xml">clientaccesspolicy.xml</a> in the root of the webserver.</li>
</ul>
<h2>Resources/links:</h2>
<div>
<ul>
<li><a  href="http://silverlight.net/forums/p/35194/106059.aspx#106059">SilverLight.net forum post on making a WCF cross domain request</a></li>
<li><a  href="http://timheuer.com/blog/archive/2008/04/06/silverlight-cross-domain-policy-file-snippet-intellisense.aspx">Cross domain policy file helpers for Visual Studio</a> &#8211; addes intellisense for the XML files</li>
<li><a  href="http://www.franksworld.com/Utilities/CrossDomainPolicyChecker/Default.aspx">Online cross domain policy file checker</a></li>
<li><a  href="http://www.leggetter.co.uk/wp-content/uploads/2008/10/silverlightcrossdomainapplication.zip">Silverlight cross domain web request example solution</a></li>
<li><a  href="http://www.leggetter.co.uk/crossdomain.xml">Example clientpolicy.xml</a> file<a  href="http://www.leggetter.co.uk/clientaccesspolicy.xml"></a></li>
<li><a href="http://www.leggetter.co.uk/clientaccesspolicy.xml">Example clientaccesspolicy.xml</a> file</li>
</ul>
</div>
<h2>The code:</h2>
<pre class="brush: csharp;">
private void RequestButton_Click(object sender, RoutedEventArgs e)
{
    try
    {
        // Create and being making the request/getting the response
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri(&quot;http://www.leggetter.co.uk/&quot;));
        request.BeginGetResponse(HandleResponse, request);
    }
    catch (Exception ex)
    {
        Debug.WriteLine(ex);
    }
}

private void HandleResponse(IAsyncResult result)
{
    try
    {
        // Finish getting the response and then read the response in chunks
        HttpWebRequest request = (HttpWebRequest)result.AsyncState;
        HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(result);

        StringBuilder readText = new StringBuilder();
        using (Stream responseStream = response.GetResponseStream())
        {
            byte[] buffer = new byte[1024];
            int read = responseStream.Read(buffer, 0, buffer.Length);
            while (read &gt; 0)
            {
                readText.Append(Encoding.UTF8.GetString(buffer, 0, read));
                read = responseStream.Read(buffer, 0, buffer.Length);
            }
        }

        // Display the response text
        Dispatcher.BeginInvoke(delegate()
        {
            ResponseText.Text = readText.ToString();
        });
    }
    catch (Exception ex)
    {
        Debug.WriteLine(ex);
    }
}
</pre><!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em> </em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.leggetter.co.uk%2F2008%2F10%2F24%2Fhow-to-make-a-cross-domain-web-request-with-silverlight-2.html&amp;title=How+to+make+a+cross+domain+web+request+with+SilverLight+2" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.leggetter.co.uk%2F2008%2F10%2F24%2Fhow-to-make-a-cross-domain-web-request-with-silverlight-2.html&amp;title=How+to+make+a+cross+domain+web+request+with+SilverLight+2" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dotnetkicks.com/kick/?url=http%3A%2F%2Fwww.leggetter.co.uk%2F2008%2F10%2F24%2Fhow-to-make-a-cross-domain-web-request-with-silverlight-2.html&amp;title=How+to+make+a+cross+domain+web+request+with+SilverLight+2" rel="nofollow" title="Add to&nbsp;DotNetKicks"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/dotnetkicks.png" title="Add to&nbsp;DotNetKicks" alt="Add to&nbsp;DotNetKicks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.leggetter.co.uk%2F2008%2F10%2F24%2Fhow-to-make-a-cross-domain-web-request-with-silverlight-2.html" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.leggetter.co.uk%2F2008%2F10%2F24%2Fhow-to-make-a-cross-domain-web-request-with-silverlight-2.html&amp;title=How+to+make+a+cross+domain+web+request+with+SilverLight+2" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.leggetter.co.uk%2F2008%2F10%2F24%2Fhow-to-make-a-cross-domain-web-request-with-silverlight-2.html&amp;title=How+to+make+a+cross+domain+web+request+with+SilverLight+2" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.leggetter.co.uk%2F2008%2F10%2F24%2Fhow-to-make-a-cross-domain-web-request-with-silverlight-2.html&amp;title=How+to+make+a+cross+domain+web+request+with+SilverLight+2" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.leggetter.co.uk%2F2008%2F10%2F24%2Fhow-to-make-a-cross-domain-web-request-with-silverlight-2.html" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+How+to+make+a+cross+domain+web+request+with+SilverLight+2+@+http%3A%2F%2Fwww.leggetter.co.uk%2F2008%2F10%2F24%2Fhow-to-make-a-cross-domain-web-request-with-silverlight-2.html" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fwww.leggetter.co.uk%2F2008%2F10%2F24%2Fhow-to-make-a-cross-domain-web-request-with-silverlight-2.html&amp;t=How+to+make+a+cross+domain+web+request+with+SilverLight+2" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->


<p>Related posts:<ol><li><a href='http://www.leggetter.co.uk/2009/10/30/using-fiddler-to-trick-silverlight-into-allowing-a-crossdomain-web-request.html' rel='bookmark' title='Permanent Link: Using Fiddler to trick Silverlight into allowing a crossdomain Web Request'>Using Fiddler to trick Silverlight into allowing a crossdomain Web Request</a></li>
<li><a href='http://www.leggetter.co.uk/2010/03/19/using-fiddler-to-help-develop-cross-domain-capable-javascript-web-applications.html' rel='bookmark' title='Permanent Link: Using Fiddler to help develop cross domain capable JavaScript web applications'>Using Fiddler to help develop cross domain capable JavaScript web applications</a></li>
<li><a href='http://www.leggetter.co.uk/2010/03/12/making-cross-domain-javascript-requests-using-xmlhttprequest-or-xdomainrequest.html' rel='bookmark' title='Permanent Link: Making cross domain JavaScript requests using XMLHttpRequest or XDomainRequest'>Making cross domain JavaScript requests using XMLHttpRequest or XDomainRequest</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.leggetter.co.uk/2008/10/24/how-to-make-a-cross-domain-web-request-with-silverlight-2.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# &#8211; Get Windows Temporary Directory</title>
		<link>http://www.leggetter.co.uk/2007/02/02/get-windows-temporary-directory.html</link>
		<comments>http://www.leggetter.co.uk/2007/02/02/get-windows-temporary-directory.html#comments</comments>
		<pubDate>Fri, 02 Feb 2007 09:25:48 +0000</pubDate>
		<dc:creator>Phil Leggetter</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[C# Snippets]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://www.leggetter.co.uk/2007/02/02/get-windows-temporary-directory.html</guid>
		<description><![CDATA[Once you know it you'll probably never forget it...but  [...]


Related posts:<ol><li><a href='http://www.leggetter.co.uk/2008/05/20/how-to-install-caplin-systems-liberator-free-edition-on-windows.html' rel='bookmark' title='Permanent Link: How to install Caplin Systems&#8217; Liberator Free Edition on Windows'>How to install Caplin Systems&#8217; Liberator Free Edition on Windows</a></li>
<li><a href='http://www.leggetter.co.uk/2009/08/28/windows-azure-503-service-unavailable.html' rel='bookmark' title='Permanent Link: Windows Azure &#8211; 503 Service Unavailable'>Windows Azure &#8211; 503 Service Unavailable</a></li>
<li><a href='http://www.leggetter.co.uk/2009/10/06/response-redirect-in-windows-azure.html' rel='bookmark' title='Permanent Link: Response.Redirect in Windows Azure'>Response.Redirect in Windows Azure</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Once you know it you&#8217;ll probably never forget it&#8230;but wait, this is the second time I&#8217;ve <a  href="http://www.google.com/search?q=C%23+get+temp+folder+path" title="Google search for C# get temp folder path">googled</a> for this. I&#8217;d best post how  you &#8220;<strong>get the Windows temporary directory using C#</strong>&#8220;!</p>
<pre class="brush: csharp;">string tempPath =
    System.IO.Path.GetTempPath();</pre><!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em> </em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.leggetter.co.uk%2F2007%2F02%2F02%2Fget-windows-temporary-directory.html&amp;title=C%23+%26%238211%3B+Get+Windows+Temporary+Directory" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.leggetter.co.uk%2F2007%2F02%2F02%2Fget-windows-temporary-directory.html&amp;title=C%23+%26%238211%3B+Get+Windows+Temporary+Directory" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dotnetkicks.com/kick/?url=http%3A%2F%2Fwww.leggetter.co.uk%2F2007%2F02%2F02%2Fget-windows-temporary-directory.html&amp;title=C%23+%26%238211%3B+Get+Windows+Temporary+Directory" rel="nofollow" title="Add to&nbsp;DotNetKicks"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/dotnetkicks.png" title="Add to&nbsp;DotNetKicks" alt="Add to&nbsp;DotNetKicks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.leggetter.co.uk%2F2007%2F02%2F02%2Fget-windows-temporary-directory.html" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.leggetter.co.uk%2F2007%2F02%2F02%2Fget-windows-temporary-directory.html&amp;title=C%23+%26%238211%3B+Get+Windows+Temporary+Directory" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.leggetter.co.uk%2F2007%2F02%2F02%2Fget-windows-temporary-directory.html&amp;title=C%23+%26%238211%3B+Get+Windows+Temporary+Directory" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.leggetter.co.uk%2F2007%2F02%2F02%2Fget-windows-temporary-directory.html&amp;title=C%23+%26%238211%3B+Get+Windows+Temporary+Directory" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.leggetter.co.uk%2F2007%2F02%2F02%2Fget-windows-temporary-directory.html" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+C%23+%26%238211%3B+Get+Windows+Temporary+Directory+@+http%3A%2F%2Fwww.leggetter.co.uk%2F2007%2F02%2F02%2Fget-windows-temporary-directory.html" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fwww.leggetter.co.uk%2F2007%2F02%2F02%2Fget-windows-temporary-directory.html&amp;t=C%23+%26%238211%3B+Get+Windows+Temporary+Directory" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://www.leggetter.co.uk/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->


<p>Related posts:<ol><li><a href='http://www.leggetter.co.uk/2008/05/20/how-to-install-caplin-systems-liberator-free-edition-on-windows.html' rel='bookmark' title='Permanent Link: How to install Caplin Systems&#8217; Liberator Free Edition on Windows'>How to install Caplin Systems&#8217; Liberator Free Edition on Windows</a></li>
<li><a href='http://www.leggetter.co.uk/2009/08/28/windows-azure-503-service-unavailable.html' rel='bookmark' title='Permanent Link: Windows Azure &#8211; 503 Service Unavailable'>Windows Azure &#8211; 503 Service Unavailable</a></li>
<li><a href='http://www.leggetter.co.uk/2009/10/06/response-redirect-in-windows-azure.html' rel='bookmark' title='Permanent Link: Response.Redirect in Windows Azure'>Response.Redirect in Windows Azure</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.leggetter.co.uk/2007/02/02/get-windows-temporary-directory.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
