<?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>Ryan McDonnell &#187; .NET</title>
	<atom:link href="http://www.ryanmcdonnell.com/category/net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ryanmcdonnell.com</link>
	<description>Pursuing Web Application Zen</description>
	<lastBuildDate>Sun, 05 Jul 2009 18:30:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>&#8220;The path  is already mapped to workspace&#8230;&#8221;</title>
		<link>http://www.ryanmcdonnell.com/the-path-is-already-mapped-to-workspace/</link>
		<comments>http://www.ryanmcdonnell.com/the-path-is-already-mapped-to-workspace/#comments</comments>
		<pubDate>Fri, 07 Dec 2007 15:00:58 +0000</pubDate>
		<dc:creator>Ryan McDonnell</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://www.ryanmcdonnell.com/the-path-is-already-mapped-to-workspace/</guid>
		<description><![CDATA[I just recently setup a new Team Foundation Server installation on a newer more powerful server. The older server was quickly taken offline. I stripped the source control bindings from old projects and proceeded to bind them to the new server. In doing so, I was given the following error:
The path &#60;path&#62; is already mapped [...]]]></description>
			<content:encoded><![CDATA[<p>I just recently setup a new Team Foundation Server installation on a newer more powerful server. The older server was quickly taken offline. I stripped the source control bindings from old projects and proceeded to bind them to the new server. In doing so, I was given the following error:</p>
<p>The path &lt;path&gt; is already mapped to workspace &lt;workspace&gt;.<br />
<span id="more-31"></span><br />
A quick search lead me to a <a href="http://blogs.msdn.com/buckh/archive/2006/09/12/path_is_already_mapped_in_workspace.aspx">post by Buck Hodges</a>, the lead developer on the Team Foundation Build team.</p>
<p>The solution is fairly easy. An XML file named VersionControl.config stores the mappings you have to each workspace and Team Foundation Server. On Vista, this file is located at:</p>
<p>C:\Users\&lt;username&gt;\AppData\Local\Microsoft\TeamFoundation\1.0\Cache\VersionControl.config</p>
<p>Open up that file and remove the appropiate &lt;ServerInfo&gt; entry that pertains to the decommissioned server.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ryanmcdonnell.com/the-path-is-already-mapped-to-workspace/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Always show the PagerTemplate in GridView control</title>
		<link>http://www.ryanmcdonnell.com/always-show-the-pagertemplate-in-gridview-control/</link>
		<comments>http://www.ryanmcdonnell.com/always-show-the-pagertemplate-in-gridview-control/#comments</comments>
		<pubDate>Wed, 01 Aug 2007 13:00:08 +0000</pubDate>
		<dc:creator>Ryan McDonnell</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://www.ryanmcdonnell.com/always-show-the-pagertemplate-in-gridview-control/</guid>
		<description><![CDATA[The PagerTemplate can be a handy place to put some frequently used controls or data in your GridView. I like to use the area to include the number and range of records displayed, some paging details and a DropDownList to let the user view more records at a time.

But what happens when the number of records doesn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>The PagerTemplate can be a handy place to put some frequently used controls or data in your GridView. I like to use the area to include the number and range of records displayed, some paging details and a DropDownList to let the user view more records at a time.<span id="more-26"></span></p>
<p><img border="0" width="488" src="http://www.ryanmcdonnell.com/wp-content/uploads/2007/08/pagertemplate1.png" alt="Sample PagerTemplate output" height="23" /></p>
<p>But what happens when the number of records doesn&#8217;t exceed the PageSize? The PagerTemplate isn&#8217;t displayed.</p>
<p>To get around that, extend the GridView in a custom server control and override the PageCount property to force the PagerTemplate to always be displayed. As long as the PageCount property is greater than one, the paging controls are rendered.</p>
<p><code>public override int PageCount {<br />
  </code><code>get {<br />
    // Override the PageCount if only one page exists to<br />
    </code><code>// force the PagerTemplate to always be displayed<br />
    int pageCount = base.PageCount;<br />
    if (pageCount == 1) {<br />
      // Only override the PageCount if the GridView.CreateChildControls is calling<br />
      </code><code>System.Diagnostics.StackFrame sf = new System.Diagnostics.StackFrame(1);<br />
      if (sf.GetMethod().Name == "CreateChildControls" &amp;&amp; sf.GetMethod().ReflectedType == typeof(GridView))<br />
      {<br />
        pageCount++;<br />
      }<br />
    }<br />
    return pageCount;<br />
  }<br />
} </code></p>
<p>The key part here is the StackFrame is looking up the stack and only returning an inflated PageCount if the calling method is the CreateChildControls method from the GridView. This keeps our PageCount number valid for display purposes and only tricks the GridView into thinking there is more than one page for purposes of forcing the paging controls to always be displayed.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ryanmcdonnell.com/always-show-the-pagertemplate-in-gridview-control/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>FileSystemWatcher fires multiple times for the same event</title>
		<link>http://www.ryanmcdonnell.com/filesystemwatcher-fires-multiple-times-for-the-same-event/</link>
		<comments>http://www.ryanmcdonnell.com/filesystemwatcher-fires-multiple-times-for-the-same-event/#comments</comments>
		<pubDate>Tue, 07 Sep 2004 08:00:54 +0000</pubDate>
		<dc:creator>Ryan McDonnell</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://www.ryanmcdonnell.com/filesystemwatcher-fires-multiple-times-for-the-same-event/</guid>
		<description><![CDATA[The FileSystemWatcher component recently gave me some headaches when firing events in response to changes to files it was watching.  In one case, when modifying a file, the FileSystemWatcher was firing four times for the same event&#8230; or so it seemed. After some research and testing, I came to the realization that four events were being [...]]]></description>
			<content:encoded><![CDATA[<p>The FileSystemWatcher component recently gave me some headaches when firing events in response to changes to files it was watching.  In one case, when modifying a file, the FileSystemWatcher was firing <strong>four</strong> times for the same event&#8230; or so it seemed.<span id="more-16"></span> After some research and testing, I came to the realization that <strong>four </strong>events were being fired. The FileSystemWatcher was doing it&#8217;s job right. I had simply disregarded the effects of anti-virus and native application file system handling. A simple change of a text file in Notepad may seem like only one file system event, but adding an anti-virus program&#8217;s checks into the mix can easily make that single event turn into four unique file system actions.</p>
<p><a href="http://www.experts-exchange.com/Programming/Languages/.NET/Q_20708008.html">http://www.experts-exchange.com/Programming/Languages/.NET/Q_20708008.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ryanmcdonnell.com/filesystemwatcher-fires-multiple-times-for-the-same-event/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Getting a file&#8217;s short name (8.3 format) in .NET</title>
		<link>http://www.ryanmcdonnell.com/getting-a-files-short-name-83-format-in-net/</link>
		<comments>http://www.ryanmcdonnell.com/getting-a-files-short-name-83-format-in-net/#comments</comments>
		<pubDate>Fri, 16 Jul 2004 08:00:24 +0000</pubDate>
		<dc:creator>Ryan McDonnell</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://www.ryanmcdonnell.com/getting-a-files-short-name-83-format-in-net/</guid>
		<description><![CDATA[Using short file names is not something that should be needed anymore, probably violates most “best practices“ and will likely be deprecated in the future. I assume this is why Microsoft did not provide an easy method for finding a file&#8217;s short name with the .NET Framework. Unfortunately, while writing an interface to an older, [...]]]></description>
			<content:encoded><![CDATA[<p>Using short file names is not something that should be needed anymore, probably violates most “best practices“ and will likely be deprecated in the future. I assume this is why Microsoft did not provide an easy method for finding a file&#8217;s short name with the .NET Framework. Unfortunately, while writing an interface to an older, poorly written application, I needed to supply the short name for some files.<span id="more-13"></span> The code below outlines how to do this. Usage should be self-explanatory. The System.Runtime.InteropServices and System.Text classes will need to be imported.</p>
<p><span style="font-size: 11px; color: black; font-family: Courier New; background-color: transparent"><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">Public</span> <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">Class</span> Interop</span><span style="font-size: 11px; color: black; font-family: Courier New; background-color: transparent">    &lt;DllImport(<span style="font-size: 11px; color: #666666; font-family: Courier New; background-color: #e4e4e4">&#8220;kernel32.dll&#8221;</span>, SetLastError:=<span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">True</span>, CharSet:=CharSet.<span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">Auto</span>)&gt; _<br />
    <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">Public</span> <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">Shared</span> <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">Function</span> GetShortPathName(<span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">ByVal</span> longPath <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">As</span> <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">String</span>, &lt;MarshalAs(UnmanagedType.LPTStr)&gt; <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">ByVal</span> ShortPath <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">As</span> StringBuilder, &lt;MarshalAs(UnmanagedType.U4)&gt; <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">ByVal</span> bufferSize <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">As</span> <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">Integer</span>) <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">As</span> <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">Integer</span><br />
    <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">End</span> <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">Function</span></p>
<p><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">End</span> <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">Class</span></p>
<p></span><span style="font-size: 11px; color: black; font-family: Courier New; background-color: transparent"><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent"><span style="font-size: 11px; color: black; font-family: Courier New; background-color: transparent"><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">Private</span> <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">Function</span> GetShortName(<span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">ByVal</span> strPath <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">As</span> <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">String</span>, <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">ByVal</span> blnIncludePath <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">As</span> <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">Boolean</span>) <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">As</span> <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">String</span><br />
    <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">Dim</span> sb <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">As</span> StringBuilder <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent">=</span> <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">New</span> StringBuilder(1024)<br />
    <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">Dim</span> retVal <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">As</span> <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">Integer</span> <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent">=</span> Interop.GetShortPathName(strPath, sb, 1024)<br />
    GetShortName <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent">=</span> sb.ToString<br />
    <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">If</span> <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent">Not</span> blnIncludePath <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">Then</span><br />
       GetShortName <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent">=</span> <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">Mid</span>(GetShortName, <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">InStrRev</span>(GetShortName, <span style="font-size: 11px; color: #666666; font-family: Courier New; background-color: #e4e4e4">&#8220;\&#8221;</span>) <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent">+</span> 1)<br />
    <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">End</span> <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">If</span><br />
<span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">End</span> <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">Function</span></span></span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ryanmcdonnell.com/getting-a-files-short-name-83-format-in-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reading data from an Excel spreadsheet with unknown sheet names</title>
		<link>http://www.ryanmcdonnell.com/reading-data-from-an-excel-spreadsheet-with-unknown-sheet-names/</link>
		<comments>http://www.ryanmcdonnell.com/reading-data-from-an-excel-spreadsheet-with-unknown-sheet-names/#comments</comments>
		<pubDate>Fri, 25 Jun 2004 08:00:24 +0000</pubDate>
		<dc:creator>Ryan McDonnell</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://www.ryanmcdonnell.com/reading-data-from-an-excel-spreadsheet-with-unknown-sheet-names/</guid>
		<description><![CDATA[Reading data from an Excel spreadsheet is pretty easy, given you know the name of the sheet in the file you are reading data from. What if you don&#8217;t know the name of the sheet? A current project I&#8217;m working on needs to give the user the ability to select the sheet name to read data [...]]]></description>
			<content:encoded><![CDATA[<p>Reading data from an Excel spreadsheet is pretty easy, given you know the name of the sheet in the file you are reading data from. What if you don&#8217;t know the name of the sheet?<span id="more-15"></span> A current project I&#8217;m working on needs to give the user the ability to select the sheet name to read data from.  Here&#8217;s a small snippet of code that reads the names of the sheets and populates a DropDownList control.</p>
<p><span style="font-size: 11px; color: black; font-family: Courier New; background-color: transparent"><span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">Dim</span> cnExcel <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">As</span> OleDbConnection <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent">=</span> <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">New</span> OleDbConnection( _<br />
    <span style="font-size: 11px; color: #666666; font-family: Courier New; background-color: #e4e4e4">&#8220;Provider=Microsoft.Jet.OLEDB.4.0;&#8221;</span> &amp;_<br />
    <span style="font-size: 11px; color: #666666; font-family: Courier New; background-color: #e4e4e4">&#8220;Data Source=&#8221;</span> &amp; strWorkbookFileName &amp; <span style="font-size: 11px; color: #666666; font-family: Courier New; background-color: #e4e4e4">&#8220;;&#8221;</span> &amp; _<br />
    <span style="font-size: 11px; color: #666666; font-family: Courier New; background-color: #e4e4e4">&#8220;Extended Properties=&#8221;"Excel 8.0;HDR=Yes&#8221;"&#8221;</span>)<br />
cnExcel.Open()<br />
<span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">Dim</span> dtSheets <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">As</span> DataTable <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent">=</span> cnExcel.GetOleDbSchemaTable( _<br />
    OleDbSchemaGuid.Tables, _<br />
    <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">New</span> <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">Object</span>() {<span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">Nothing</span>, <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">Nothing</span>, <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">Nothing</span>, <span style="font-size: 11px; color: #666666; font-family: Courier New; background-color: #e4e4e4">&#8220;Table&#8221;</span>})<br />
<span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">Dim</span> i <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">As</span> <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">Integer</span><br />
<span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">Dim</span> strWorksheetName <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">As</span> <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">String</span><br />
<span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">For</span> i <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent">=</span> 0 <span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">To</span> dtSheets.Rows.<span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">Count</span> <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent">-</span> 1<br />
    strWorksheetName <span style="font-size: 11px; color: red; font-family: Courier New; background-color: transparent">=</span> dtSheets.Rows(i)(2)<br />
    dropWorksheetName.Items.<span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">Add</span>(<span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">New</span> ListItem(strWorksheetName, strWorksheetName))<br />
<span style="font-size: 11px; color: blue; font-family: Courier New; background-color: transparent">Next</span><br />
cnExcel.Close()</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ryanmcdonnell.com/reading-data-from-an-excel-spreadsheet-with-unknown-sheet-names/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
