Archive for the ‘Technology’ Category

VirtualWiFi - The Basics

Friday, December 4th, 2009

In basic terms, VirtualWiFi in Windows 7 is nothing but, connecting to multiple IEEE 802.11 networks using one WiFi card.

VirtualWiFi is a project Microsoft have been working on from 2002. Not being worked on now, not event supported by Microsoft research. They have provided VirtualWiFi OID support in Windows 7.
(more…)

Getting Windows Vista and Windows 7 OS name using C#

Wednesday, February 18th, 2009

With Windows Vista getting popular and Windows 7 fast approaching there will soon be a lot of applications running on these platform. Some of the scenarios need to read the OS name dynamically from code. The commonly used method is to extract the OS name using System.OperatingSystem object. It provides a Platform and version number using which you can deduce the OS name.

(more…)

ASP.NET MVC Action filters

Wednesday, January 14th, 2009

I love the really cool Action Filter’s in ASP.Net MVC. I use it to keep my code clean and reusable. This post is not about what is an Action Filter but is more about how to use them to have cleaner and reusable components.
(more…)

Calculating width of TextBox dynamically based on Text in C#

Tuesday, December 23rd, 2008

Sometimes we need to expand the TextBox dynamically based on the length of the entered text. TextBox does not have a AutoSize property by which it can adjust it’s size based on the content. On way of calculating the Width for the TextBox is using the Graphics.MeasureString and calculating the Pixel width. This method has it’s Pros and cons.

(more…)

Detecting removable drive types using C#

Thursday, November 20th, 2008

Ever wanted to find out the different drives or just the removable drives on the machine ?? The DriveInfo class is the answer to your prayers.

(more…)

IIS7 Executing Directory

Monday, October 27th, 2008

Generally we get the executing directory path using the HttpContext.Request.PhysicalPath etc. In IIS7 this won’t work. We cannot access the HttpContext.Request object in Global.ascx.
This is the way to do this,

int binPos = HttpRuntime.BinDirectory.LastIndexOf("\\bin");
string executingDirectory = HttpRuntime.BinDirectory.Remove(binPos);

Have fun.

WPF Dispatcher CheckAccess not displaying in intellisense

Thursday, October 16th, 2008

This one really struck me hard. I am doing a threading scenario with some UI feedback marshaled back on the UI thread. And you won’t believe it, I am amazed to find CheckAccess missing from the Dispatcher object. Intellisense wouldn’t just show me CheckAccess(). Rubbing my eyes and again checking, it still seems to have vanished…

(more…)

C# Converting Time between TimeZones in C#

Thursday, October 2nd, 2008

.Net 3.5 has introduced a new TimeZoneInfo class which is an improvement over the existing TimeZone class. The TimeZone class can work on local TimeZone only i.e. converting between UTC and Local time zone only. The new TimeZoneInfo class provide much more richer functionality of working with different other Time zone’s.
(more…)

Get user IP address

Thursday, September 25th, 2008

Well, yes, it looks like trivial but it isn’t. Many a times we need to get the IP address of the user. There are a handful of suggestions to do this. I discuss the methods and the short comings in them.
(more…)

Error on attaching an SQL Server database

Tuesday, August 5th, 2008

Certain times we get an error while attaching an mdf file saying,

The file “D:\DataBaseFile.mdf” is compressed but does not reside in a read-only database or filegroup. The file must be decompressed.
Could not open new database ‘D:\DataBaseFile.mdf’. CREATE DATABASE is aborted.

(more…)