Find All Data Providers Installed On A Machine
- By Deepak
- 29 July, 2010
- 3 Comments
This post shows you how to find Data Providers installed on a machine. Data providers in .NET Framework provide the plumbing necessary to connect to databases. There are different data … Continue Reading →
Get Current Windows User In C#
- By Deepak
- 12 May, 2009
- No Comments
This snippet will show you how to get the currently logged in user on windows.
|
1 2 3 4 |
System.Security.Principal.WindowsIdentity identity = System.Security.Principal.WindowsIdentity.GetCurrent(); Console.WriteLine(identity.Name); |
Get Windows Registry Size With WMI And C#
- By Deepak
- 29 March, 2009
- 2 Comments
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.
|
1 2 3 4 5 6 7 8 |
ManagementObjectSearcher mgmtObjects = new ManagementObjectSearcher("Select * from Win32_Registry"); foreach (var item in mgmtObjects.Get()) { Console.WriteLine(string.Format("Current Size: {0}MB", item["CurrentSize"])); Console.WriteLine(string.Format("Maximum Size: {0}MB", item["MaximumSize"])); } |
The output.
Reverse Array Elements Using C#
- By Deepak
- 26 March, 2009
- 5 Comments
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 … Continue Reading →
Convert Hexadecimal To Number In C#
- By Deepak
- 24 March, 2009
- No Comments
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.
|
1 |
int number = Convert.ToInt32("BB", 16); |
Get Free Disk Space Using T-SQL
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 … Continue Reading →
SQL Server 2008 – Get All Indexes In A Database
- By Deepak
- 24 March, 2009
- No Comments
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 … Continue Reading →
Get Name Of Current Executing Assembly In C#
- By Deepak
- 23 March, 2009
- No Comments
This is where reflection comes in handy. The following code snippet shows you how to get the name of executing assembly.
|
1 2 3 |
string assemblyName; assemblyName = System.Reflection.Assembly.GetExecutingAssembly().FullName; Console.WriteLine(assemblyName); |
Output for the above code returns the fully … Continue Reading →
Get CD Or DVD Drive Information Using WMI And C#
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 … Continue Reading →
Get Last Row From Table Using LINQ To SQL
- By Deepak
- 9 March, 2009
- No Comments
This query returns the last row from Sales.Customer table in Adventure Works database. I am using LINQPad to write and execute my query.
|
1 2 3 |
(from c in Customers select c) .OrderByDescending(x=> x.CustomerID).First() |
Here is the result as displayed … Continue Reading →





Copyright © 2013