Thursday, October 9, 2008

How to read disk drive information using C#

I just came across some cool C# code while preparing for the Microsoft 70-536 exam. Using the Windows Management Instrumentation (WMI), you can inspect a machine for available disk drives. Add the System.Management assembly as a reference in your project, and off you go:

ManagementScope DemoScope=new ManagementScope("\\\\enter_machine_name_here\\root\\cimv2");
ObjectQuery DemoQuery = new ObjectQuery("SELECT Size, Name FROM Win32_LogicalDisk WHERE DriveType=3");
ManagementObjectSearcher DemoSearcher = new ManagementObjectSearcher(DemoScope, DemoQuery);
ManagementObjectCollection AllObjects = DemoSearcher.Get();
foreach (ManagementObject DemoObject in AllObjects)
Console.WriteLine("Resource Name:" + DemoObject["Name"].ToString());
Console.WriteLine("Resource Size:" + DemoObject["Size"].ToString());

Thursday, October 2, 2008

Where does my stuff come from?

If you have ever wondered where the casing from your cell phone was made, or how much of an impact throwing away a juice box makes on environment, this video is for you. I found Story of Stuff linked on Damien Rice’s MySpace page. The website shows a very well done video explanation of where “stuff” comes from. Not only where it comes from, but we should think twice about using that stuff.

SPOILER WARNING: This video is not a I-feel-so-guilty-I-am-going-to-live-in-a-shack-in-the-woods kind of presentation. It was produced to let everyday people know that there is a story behind our large amounts of stuff. It does not just appear magically on the shelves at Kroger.

Link: Story of Stuff