TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Josh Dycus
NA
11
20.5k
Hard Drive Information with WMI
Oct 18 2010 5:01 PM
Hello,
I am trying to retrieve system information using WMI. Everything is working good until I got to the Hard Drive. I am trying to populate the Drive size for the local Hard Drives on the system. The issue is at runtime it only populate the first drive and does not go beyond that. I am still fairly new to C#. Here is the snippet for the Hard Drive:
public string GetHardDrive()
{
double disk = 0;
ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2",
"SELECT * FROM Win32_LogicalDisk where DriveType=3");
foreach (ManagementObject wmi in searcher.Get())
{
try
{
disk = Math.Round(((((double)Convert.ToDouble(wmi["Size"]) / 1024) / 1024) / 1024), 2);
return disk.ToString();
}
catch
{
}
}
return "Unable to Find Drive";
}
Any Help would be appreciated.
Thanks in advance.
Reply
Answers (
7
)
Child MDI force Parent MDI to open new child.
Problem with creating a login form