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
Rajiv Yelkawar
NA
5
0
Displaying drive information
Mar 5 2010 10:35 PM
I am new to C#. I am not able to retreive information about all drives in my laptop. I used following code.
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace IOEx
{
class DriveList
{
static void Main()
{
foreach (DriveInfo drvInfo in DriveInfo.GetDrives())
{
try
{
//if (drvInfo.IsReady)
{
Console.WriteLine("Drive {0} ({1}), free space {2:#,#} GB Total space ({3: #,#}) GB", drvInfo.Name, drvInfo.VolumeLabel, drvInfo.TotalFreeSpace, drvInfo.TotalSize);
}
}
catch(Exception ex)
{
Console.WriteLine("Application generated exception : "+ex.Message);
}
Console.ReadKey();
}
}
}
}
the laptop has hard disk with two partitions and a CD rom. The output displayed shows information about C drive only that too considering entire physical drive. program do not detect CD rom. Can somebody explain.
Reply
Answers (
4
)
Constructor
adding items in a table whose contents are displayed in a combo box