<?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>One .NET Way &#187; Code Snippets</title>
	<atom:link href="http://www.onedotnetway.com/category/codesnippets/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.onedotnetway.com</link>
	<description>Everything .Net</description>
	<lastBuildDate>Thu, 20 May 2010 03:38:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Get Current Windows User In C#</title>
		<link>http://www.onedotnetway.com/get-current-windows-user-in-c/</link>
		<comments>http://www.onedotnetway.com/get-current-windows-user-in-c/#comments</comments>
		<pubDate>Tue, 12 May 2009 00:34:03 +0000</pubDate>
		<dc:creator>Deepak</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.onedotnetway.com/get-current-windows-user-in-c/</guid>
		<description><![CDATA[This snippet will show you how to get the currently logged in user on windows. 
System.Security.Principal.WindowsIdentity identity =
  System.Security.Principal.WindowsIdentity.GetCurrent();

Console.WriteLine(identity.Name);
Post from: One .Net Way
Get Current Windows User In C#
<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/get-current-windows-user-in-c/">Get Current Windows User In C#</a></p>
]]></description>
			<content:encoded><![CDATA[<p>This snippet will show you how to get the currently logged in user on windows. </p>
<pre class="code">System.Security.Principal.<span style="color: #2b91af">WindowsIdentity </span>identity =
  System.Security.Principal.<span style="color: #2b91af">WindowsIdentity</span>.GetCurrent();

<span style="color: #2b91af">Console</span>.WriteLine(identity.Name);</pre>
<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/get-current-windows-user-in-c/">Get Current Windows User In C#</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.onedotnetway.com/get-current-windows-user-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get Width And Height Of Image In C#</title>
		<link>http://www.onedotnetway.com/get-width-and-height-of-image-in-c/</link>
		<comments>http://www.onedotnetway.com/get-width-and-height-of-image-in-c/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 10:00:55 +0000</pubDate>
		<dc:creator>Deepak</dc:creator>
				<category><![CDATA[Code Snippets]]></category>

		<guid isPermaLink="false">http://www.onedotnetway.com/get-width-and-height-of-image-in-c/</guid>
		<description><![CDATA[To get width and height of an image we can use System.Drawing.Image class. This code snippet shows how to retrieve width and height of an image.

string filePath = @&#34;c:\deepak\MeeGo.jpg&#34;;
Image img = Image.FromFile(filePath);
&#160;
Console.WriteLine(string.Format(&#34;Height: {0}&#34;,img.Size.Height));
&#160;
Console.WriteLine(string.Format(&#34;Width: {0}&#34;,img.Size.Width));

Post from: One .Net Way
Get Width And Height Of Image In C#
<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/get-width-and-height-of-image-in-c/">Get Width And Height Of Image In C#</a></p>
]]></description>
			<content:encoded><![CDATA[<p>To get width and height of an image we can use System.Drawing.Image class. This code snippet shows how to retrieve width and height of an image.</p>
<div style="font-family: courier new; background: white; color: black; font-size: 10pt">
<pre style="margin: 0px"><span style="color: blue">string</span> filePath = <span style="color: #a31515">@&quot;c:\deepak\MeeGo.jpg&quot;</span>;</pre>
<pre style="margin: 0px"><span style="color: #2b91af">Image</span> img = <span style="color: #2b91af">Image</span>.FromFile(filePath);</pre>
<pre style="margin: 0px">&#160;</pre>
<pre style="margin: 0px"><span style="color: #2b91af">Console</span>.WriteLine(<span style="color: blue">string</span>.Format(<span style="color: #a31515">&quot;Height: {0}&quot;</span>,img.Size.Height));</pre>
<pre style="margin: 0px">&#160;</pre>
<pre style="margin: 0px"><span style="color: #2b91af">Console</span>.WriteLine(<span style="color: blue">string</span>.Format(<span style="color: #a31515">&quot;Width: {0}&quot;</span>,img.Size.Width));</pre>
</div>
<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/get-width-and-height-of-image-in-c/">Get Width And Height Of Image In C#</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.onedotnetway.com/get-width-and-height-of-image-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get Windows Registry Size With WMI And C#</title>
		<link>http://www.onedotnetway.com/get-windows-registry-size-with-wmi-and-c/</link>
		<comments>http://www.onedotnetway.com/get-windows-registry-size-with-wmi-and-c/#comments</comments>
		<pubDate>Sun, 29 Mar 2009 05:42:46 +0000</pubDate>
		<dc:creator>Deepak</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[WMI]]></category>

		<guid isPermaLink="false">http://www.onedotnetway.com/get-windows-registry-size-with-wmi-and-c/</guid>
		<description><![CDATA[Windows Registry Size can be retrieved using WMI objects. This code snippet shows you how to get current size and maximum size for Windows registry.
ManagementObjectSearcher mgmtObjects = 
  new ManagementObjectSearcher(&#34;Select * from Win32_Registry&#34;);

foreach (var item in mgmtObjects.Get())
{
  Console.WriteLine(string.Format(&#34;Current Size: {0}MB&#34;, item[&#34;CurrentSize&#34;]));
  Console.WriteLine(string.Format(&#34;Maximum Size: {0}MB&#34;, item[&#34;MaximumSize&#34;]));
}

&#160;
The output.

Post from: One .Net Way
Get Windows Registry [...]<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/get-windows-registry-size-with-wmi-and-c/">Get Windows Registry Size With WMI And C#</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Windows Registry Size can be retrieved using WMI objects. This code snippet shows you how to get current size and maximum size for Windows registry.</p>
<pre class="code"><span style="color: #2b91af">ManagementObjectSearcher </span>mgmtObjects = </pre>
<pre class="code">  <span style="color: blue">new </span><span style="color: #2b91af">ManagementObjectSearcher</span>(<span style="color: #a31515">&quot;Select * from Win32_Registry&quot;</span>);

<span style="color: blue">foreach </span>(<span style="color: blue">var </span>item <span style="color: blue">in </span>mgmtObjects.Get())
{
<span style="color: #2b91af">  Console</span>.WriteLine(<span style="color: blue">string</span>.Format(<span style="color: #a31515">&quot;Current Size: {0}MB&quot;</span>, item[<span style="color: #a31515">&quot;CurrentSize&quot;</span>]));
<span style="color: #2b91af">  Console</span>.WriteLine(<span style="color: blue">string</span>.Format(<span style="color: #a31515">&quot;Maximum Size: {0}MB&quot;</span>, item[<span style="color: #a31515">&quot;MaximumSize&quot;</span>]));
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>&#160;</p>
<p>The output.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Windows Registry Size" border="0" alt="Windows Registry Size" src="http://www.onedotnetway.com/wp-content/uploads/2009/03/image45.png" width="186" height="41" /></p>
<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/get-windows-registry-size-with-wmi-and-c/">Get Windows Registry Size With WMI And C#</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.onedotnetway.com/get-windows-registry-size-with-wmi-and-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reverse Array Elements Using C#</title>
		<link>http://www.onedotnetway.com/reverse-array-elements-using-c/</link>
		<comments>http://www.onedotnetway.com/reverse-array-elements-using-c/#comments</comments>
		<pubDate>Thu, 26 Mar 2009 02:01:13 +0000</pubDate>
		<dc:creator>Deepak</dc:creator>
				<category><![CDATA[Code Snippets]]></category>

		<guid isPermaLink="false">http://www.onedotnetway.com/reverse-array-elements-using-c/</guid>
		<description><![CDATA[In .Net Framework reversing array elements can be done by using Reverse method on Array type. This code snippet shows you how this method can be used to reverse an array. 
// Declare an array with 10 elements
int[] numbers = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

// Output [...]<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/reverse-array-elements-using-c/">Reverse Array Elements Using C#</a></p>
]]></description>
			<content:encoded><![CDATA[<p>In .Net Framework reversing array elements can be done by using Reverse method on Array type. This code snippet shows you how this method can be used to reverse an array. </p>
<pre class="code"><span style="color: green">// Declare an array with 10 elements
</span><span style="color: blue">int</span>[] numbers = <span style="color: blue">new int</span>[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

<span style="color: green">// Output elements in original order
</span><span style="color: blue">for </span>(<span style="color: blue">int </span>i = 0; i &lt; numbers.Length; i++)
{
<span style="color: #2b91af">  Console</span>.Write(<span style="color: #a31515">&quot; {0}&quot;</span>, numbers[i]);
}
<span style="color: #2b91af">Console</span>.WriteLine();

<span style="color: green">// Reverse the array
</span><span style="color: #2b91af">Array</span>.Reverse(numbers);

<span style="color: green">// Output elements with changed order
</span><span style="color: blue">for </span>(<span style="color: blue">int </span>i = 0; i &lt; numbers.Length; i++)
{
<span style="color: #2b91af">  Console</span>.Write(<span style="color: #a31515">&quot; {0}&quot;</span>, numbers[i]);
}

<span style="color: #2b91af">Console</span>.ReadKey();</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Here is the output.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.onedotnetway.com/wp-content/uploads/2009/03/image42.png" width="208" height="45" /> </p>
<p>Array.Reverse method also provides an overload which can be used to reverse elements at a given indexes. For example we want to reverse elements 3, 4 and 5 but leave others intact. This can be achieved using the following code snippet.</p>
<pre class="code"><span style="color: green">// Declare an array with 10 elements
</span><span style="color: blue">int</span>[] numbers = <span style="color: blue">new int</span>[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

<span style="color: green">// Output elements in original order
</span><span style="color: blue">for </span>(<span style="color: blue">int </span>i = 0; i &lt; numbers.Length; i++)
{
<span style="color: #2b91af">   Console</span>.Write(<span style="color: #a31515">&quot; {0}&quot;</span>, numbers[i]);
}
<span style="color: #2b91af">Console</span>.WriteLine();

<span style="color: green">// Reverse numbers 3 , 4 and 5
</span><span style="color: #2b91af">Array</span>.Reverse(numbers, 2, 3);

<span style="color: green">// Output elements with changed order
</span><span style="color: blue">for </span>(<span style="color: blue">int </span>i = 0; i &lt; numbers.Length; i++)
{
<span style="color: #2b91af">  Console</span>.Write(<span style="color: #a31515">&quot; {0}&quot;</span>, numbers[i]);
}

<span style="color: #2b91af">Console</span>.ReadKey();</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>And the output is.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.onedotnetway.com/wp-content/uploads/2009/03/image43.png" width="186" height="59" /></p>
<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/reverse-array-elements-using-c/">Reverse Array Elements Using C#</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.onedotnetway.com/reverse-array-elements-using-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Convert Hexadecimal To Number In C#</title>
		<link>http://www.onedotnetway.com/convert-hexadecimal-to-number-in-c/</link>
		<comments>http://www.onedotnetway.com/convert-hexadecimal-to-number-in-c/#comments</comments>
		<pubDate>Tue, 24 Mar 2009 10:53:49 +0000</pubDate>
		<dc:creator>Deepak</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.onedotnetway.com/convert-hexadecimal-to-number-in-c/</guid>
		<description><![CDATA[To convert a Hexadecimal to a number we can use an overload of Convert.ToInt32 method.
 
Using the overload I can convert for example hex string “BB” to a number.
int number = Convert.ToInt32(&#34;BB&#34;, 16);

And the number variable gets assigned value of 187.
Post from: One .Net Way
Convert Hexadecimal To Number In C#
<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/convert-hexadecimal-to-number-in-c/">Convert Hexadecimal To Number In C#</a></p>
]]></description>
			<content:encoded><![CDATA[<p>To convert a Hexadecimal to a number we can use an overload of Convert.ToInt32 method.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Convert.ToInt32" border="0" alt="Convert.ToInt32" src="http://www.onedotnetway.com/wp-content/uploads/2009/03/image41.png" width="397" height="57" /> </p>
<p>Using the overload I can convert for example hex string “BB” to a number.</p>
<pre class="code"><span style="color: blue">int </span>number = <span style="color: #2b91af">Convert</span>.ToInt32(<span style="color: #a31515">&quot;BB&quot;</span>, 16);</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>And the number variable gets assigned value of 187.</p>
<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/convert-hexadecimal-to-number-in-c/">Convert Hexadecimal To Number In C#</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.onedotnetway.com/convert-hexadecimal-to-number-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get Free Disk Space Using T-SQL</title>
		<link>http://www.onedotnetway.com/get-free-disk-space-using-t-sql/</link>
		<comments>http://www.onedotnetway.com/get-free-disk-space-using-t-sql/#comments</comments>
		<pubDate>Tue, 24 Mar 2009 10:41:58 +0000</pubDate>
		<dc:creator>Deepak</dc:creator>
				<category><![CDATA[Code Snippets]]></category>

		<guid isPermaLink="false">http://www.onedotnetway.com/get-free-disk-space-using-t-sql/</guid>
		<description><![CDATA[To get free disk space for all physical drives on a machine we can use xp_fixeddrives extended stored procedure. An interesting this about this procedure is that it is not documented in books online.
EXEC xp_fixeddrives

Here is output on my machine.

Post from: One .Net Way
Get Free Disk Space Using T-SQL
<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/get-free-disk-space-using-t-sql/">Get Free Disk Space Using T-SQL</a></p>
]]></description>
			<content:encoded><![CDATA[<p>To get free disk space for all physical drives on a machine we can use xp_fixeddrives extended stored procedure. An interesting this about this procedure is that it is not documented in books online.</p>
<pre class="code"><span style="color: blue">EXEC </span><span style="color: maroon">xp_fixeddrives</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Here is output on my machine.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="xp_fixeddrives" border="0" alt="xp_fixeddrives" src="http://www.onedotnetway.com/wp-content/uploads/2009/03/image40.png" width="161" height="46" /></p>
<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/get-free-disk-space-using-t-sql/">Get Free Disk Space Using T-SQL</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.onedotnetway.com/get-free-disk-space-using-t-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Server 2008 &#8211; Get All Indexes In A Database</title>
		<link>http://www.onedotnetway.com/sql-server-2008-get-all-indexes-in-a-database/</link>
		<comments>http://www.onedotnetway.com/sql-server-2008-get-all-indexes-in-a-database/#comments</comments>
		<pubDate>Tue, 24 Mar 2009 10:26:31 +0000</pubDate>
		<dc:creator>Deepak</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://www.onedotnetway.com/sql-server-2008-get-all-indexes-in-a-database/</guid>
		<description><![CDATA[You’ve got to love sys views in SQL Server. While learning about performance tuning on SQL Server 2008 I wanted to get a list of all Indexes on my database and the answer was as simple as it can be. Here i a statement which can be used to get a list of all indexes [...]<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/sql-server-2008-get-all-indexes-in-a-database/">SQL Server 2008 &ndash; Get All Indexes In A Database</a></p>
]]></description>
			<content:encoded><![CDATA[<p>You’ve got to love sys views in SQL Server. While learning about performance tuning on SQL Server 2008 I wanted to get a list of all Indexes on my database and the answer was as simple as it can be. Here i a statement which can be used to get a list of all indexes on a database.</p>
<pre class="code"><span style="color: blue">SELECT </span><span style="color: gray">* </span><span style="color: blue">FROM </span><span style="color: green">sys</span><span style="color: gray">.</span><span style="color: green">indexes</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>And here is the partial output from AdventureWorks database.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="sys.indexes" border="0" alt="sys.indexes" src="http://www.onedotnetway.com/wp-content/uploads/2009/03/image39.png" width="458" height="279" /></p>
<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/sql-server-2008-get-all-indexes-in-a-database/">SQL Server 2008 &ndash; Get All Indexes In A Database</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.onedotnetway.com/sql-server-2008-get-all-indexes-in-a-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get Name Of Current Executing Assembly In C#</title>
		<link>http://www.onedotnetway.com/get-name-of-current-executing-assembly-in-c/</link>
		<comments>http://www.onedotnetway.com/get-name-of-current-executing-assembly-in-c/#comments</comments>
		<pubDate>Mon, 23 Mar 2009 01:34:55 +0000</pubDate>
		<dc:creator>Deepak</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.onedotnetway.com/get-name-of-current-executing-assembly-in-c/</guid>
		<description><![CDATA[This is where reflection comes in handy. The following code snippet shows you how to get the name of executing assembly.
string assemblyName;
assemblyName = System.Reflection.Assembly.GetExecutingAssembly().FullName;
Console.WriteLine(assemblyName);

&#160;
Output for the above code returns the fully qualified name as shown below
 
&#160;
To just get the Assembly name we can use this snippet.
string assemblyName;
assemblyName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
Console.WriteLine(assemblyName);

Here is the output.

Post from: One [...]<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/get-name-of-current-executing-assembly-in-c/">Get Name Of Current Executing Assembly In C#</a></p>
]]></description>
			<content:encoded><![CDATA[<p>This is where reflection comes in handy. The following code snippet shows you how to get the name of executing assembly.</p>
<pre class="code"><span style="color: blue">string </span>assemblyName;
assemblyName = System.Reflection.<span style="color: #2b91af">Assembly</span>.GetExecutingAssembly().FullName;
<span style="color: #2b91af">Console</span>.WriteLine(assemblyName);</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>&#160;</p>
<p>Output for the above code returns the fully qualified name as shown below</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.onedotnetway.com/wp-content/uploads/2009/03/image36.png" width="540" height="40" /> </p>
<p>&#160;</p>
<p>To just get the Assembly name we can use this snippet.</p>
<pre class="code"><span style="color: blue">string </span>assemblyName;
assemblyName = System.Reflection.<span style="color: #2b91af">Assembly</span>.GetExecutingAssembly().GetName().Name;
<span style="color: #2b91af">Console</span>.WriteLine(assemblyName);</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Here is the output.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.onedotnetway.com/wp-content/uploads/2009/03/image37.png" width="245" height="48" /></p>
<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/get-name-of-current-executing-assembly-in-c/">Get Name Of Current Executing Assembly In C#</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.onedotnetway.com/get-name-of-current-executing-assembly-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get CD Or DVD Drive Information Using WMI And C#</title>
		<link>http://www.onedotnetway.com/get-cd-or-dvd-drive-information-using-wmi-and-c/</link>
		<comments>http://www.onedotnetway.com/get-cd-or-dvd-drive-information-using-wmi-and-c/#comments</comments>
		<pubDate>Mon, 09 Mar 2009 05:22:27 +0000</pubDate>
		<dc:creator>Deepak</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[WMI]]></category>

		<guid isPermaLink="false">http://www.onedotnetway.com/get-cd-or-dvd-drive-information-using-wmi-and-c/</guid>
		<description><![CDATA[This snippet shows you how to get information about all CD / DVD drives on your machine using WMI and C#. To run the code you need to add reference to System.Management.
ManagementObjectSearcher mgmtObjects = 
  new ManagementObjectSearcher(&#34;Select * from Win32_CDROMDrive&#34;);

foreach (var item in mgmtObjects.Get())
{
  Console.WriteLine(&#34;Drive Letter - \t&#34; + item[&#34;Drive&#34;]);
  Console.WriteLine(&#34;Name - [...]<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/get-cd-or-dvd-drive-information-using-wmi-and-c/">Get CD Or DVD Drive Information Using WMI And C#</a></p>
]]></description>
			<content:encoded><![CDATA[<p>This snippet shows you how to get information about all CD / DVD drives on your machine using WMI and C#. To run the code you need to add reference to System.Management.</p>
<pre class="code"><span style="color: #2b91af">ManagementObjectSearcher </span>mgmtObjects = </pre>
<pre class="code">  <span style="color: blue">new </span><span style="color: #2b91af">ManagementObjectSearcher</span>(<span style="color: #a31515">&quot;Select * from Win32_CDROMDrive&quot;</span>);

<span style="color: blue">foreach </span>(<span style="color: blue">var </span>item <span style="color: blue">in </span>mgmtObjects.Get())
{
<span style="color: #2b91af">  Console</span>.WriteLine(<span style="color: #a31515">&quot;Drive Letter - \t&quot; </span>+ item[<span style="color: #a31515">&quot;Drive&quot;</span>]);
<span style="color: #2b91af">  Console</span>.WriteLine(<span style="color: #a31515">&quot;Name - \t&quot; </span>+ item[<span style="color: #a31515">&quot;Name&quot;</span>]);
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>&#160;</p>
<p>This code snippet will print out the letter and the name of all CD or DVD drives on a machine. Here is the output on my PC.</p>
<p><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="54" alt="image" src="http://www.onedotnetway.com/wp-content/uploads/2009/03/image7.png" width="378" border="0" /></p>
<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/get-cd-or-dvd-drive-information-using-wmi-and-c/">Get CD Or DVD Drive Information Using WMI And C#</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.onedotnetway.com/get-cd-or-dvd-drive-information-using-wmi-and-c/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Get Last Row From Table Using LINQ To SQL</title>
		<link>http://www.onedotnetway.com/get-last-row-from-table-using-linq-to-sql/</link>
		<comments>http://www.onedotnetway.com/get-last-row-from-table-using-linq-to-sql/#comments</comments>
		<pubDate>Mon, 09 Mar 2009 02:17:19 +0000</pubDate>
		<dc:creator>Deepak</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[LINQ]]></category>

		<guid isPermaLink="false">http://www.onedotnetway.com/get-last-row-from-table-using-linq-to-sql/</guid>
		<description><![CDATA[This query returns the last row from Sales.Customer table in Adventure Works database. I am using LINQPad to write and execute my query. 
(from c in Customers
select c)
.OrderByDescending(x=&#62; x.CustomerID).First()
&#160;
Here is the result as displayed in LINQPad
&#160; 

Post from: One .Net Way
Get Last Row From Table Using LINQ To SQL
<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/get-last-row-from-table-using-linq-to-sql/">Get Last Row From Table Using LINQ To SQL</a></p>
]]></description>
			<content:encoded><![CDATA[<p>This query returns the last row from Sales.Customer table in Adventure Works database. I am using LINQPad to write and execute my query. </p>
<pre class="code"><span style="color: black">(</span><span style="color: blue">from </span><span style="color: black">c </span><span style="color: blue">in </span><span style="color: black">Customers</span></pre>
<pre class="code"><span style="color: black"></span><span style="color: blue">select </span><span style="color: black">c)</span></pre>
<pre class="code"><span style="color: black">.OrderByDescending(x=&gt; x.CustomerID).First()</span></pre>
<p>&#160;</p>
<p>Here is the result as displayed in LINQPad</p>
<p>&#160;<img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="177" alt="image" src="http://www.onedotnetway.com/wp-content/uploads/2009/03/image6.png" width="425" border="0" /> </p>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Post from: <a href="http://www.onedotnetway.com">One .Net Way</a></p>
<p><a href="http://www.onedotnetway.com/get-last-row-from-table-using-linq-to-sql/">Get Last Row From Table Using LINQ To SQL</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.onedotnetway.com/get-last-row-from-table-using-linq-to-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
