473,473 Members | 1,886 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Getting volume information

My objective is to get the "label" information for the different
volumes that are mounted. I want to display the same information as
Windows Explorer. I wrote this test code with gets me the drive
letter, but the label is always blank. Any thoughts?

DriveInfo[] drives = DriveInfo.GetDrives();

foreach (DriveInfo di in drives)
{
Console.WriteLine("----------------------");
if (di.IsReady)
{
Console.WriteLine("label: {0}", di.VolumeLabel);
Console.WriteLine("Format: {0}", di.DriveFormat);
Console.WriteLine("Name: {0}", di.Name);
}
Console.WriteLine("Root Directory: {0}", di.RootDirectory);
Console.WriteLine("Type: {0}", di.DriveType);
Console.WriteLine("Is Ready: {0}", di.IsReady);
}

Jan 3 '07 #1
4 4749
Hi,

Your code should work fine, did you check in your explorer and make sure
you have a label?

"herc" <ca******@gmail.comwrote in message
news:11*********************@48g2000cwx.googlegrou ps.com...
My objective is to get the "label" information for the different
volumes that are mounted. I want to display the same information as
Windows Explorer. I wrote this test code with gets me the drive
letter, but the label is always blank. Any thoughts?

DriveInfo[] drives = DriveInfo.GetDrives();

foreach (DriveInfo di in drives)
{
Console.WriteLine("----------------------");
if (di.IsReady)
{
Console.WriteLine("label: {0}", di.VolumeLabel);
Console.WriteLine("Format: {0}", di.DriveFormat);
Console.WriteLine("Name: {0}", di.Name);
}
Console.WriteLine("Root Directory: {0}", di.RootDirectory);
Console.WriteLine("Type: {0}", di.DriveType);
Console.WriteLine("Is Ready: {0}", di.IsReady);
}

Jan 3 '07 #2
Gandalf,

This is interesting, here is what I get when I run the program, or at
least part of it:
----------------------
Root Directory: D:\
Type: CDRom
Is Ready: False
----------------------
Root Directory: E:\
Type: CDRom
Is Ready: False
----------------------
Root Directory: F:\
Type: CDRom
Is Ready: False
----------------------
label:
Format: NTFS
Name: G:\
Root Directory: G:\
Type: Network
Is Ready: True
----------------------

When I look at Windows Explorer (running XPSP2), things are displayed
this way:

DVD Drive (D:)
DVD-RW Drive (E:)
DVD Drive (F:)
cartoof on '172.16.52.2' (G:)

How is it getting that the CDRom's are really DVD's and DVD-RW and how
is it getting the actual share name of the network drive mounted to G:?
I am trying to develop to the lowest common factor, thus more
information is ideal;)
WhiteWizard wrote:
Herc,

I copied your code into a console app and it runs fine for me. Maybe your
drives really don't have a label?

WhiteWizard(aka Gandalf)
MCSD.NET, MCAD, MCT
Jan 3 '07 #3
An extra note:

My real objective is to know the difference in removable drives. I
don't want to mess with the floppies, but I do need to know which
drives are external hard drives and which are card readers.

Jan 3 '07 #4
When I say Card Reader, I am refering to all the flash cards that are
out there today for digital cameras and MP3 players.

WhiteWizard wrote:
I just had another thought (doesn't happen often I have to brag when it does :)
Nice to know that I am not the only one!
Do you you any media actually IN the drives when you run your code? I think
my DVD/CD drive just shows as yours does when it is empty, but shows a "Audio
CD" when loaded with one.

That would only leave your network drive without a name...possible it really
doesn't have one?
Gandalf,

What I am looking for is as much detailed info about the hardware as is
avalable. I would like to have more then just the label of the volume.
But to answer your question, I do not have media in any of the optical
drives which is why I not really expecting a label there. BUT Windows
Explorer knows that one is a DVD-RW and the other is a DVD, not simply
a CD Rom. The question is: how?

With respect to the network labels, it does seem a bit strange that
yours have labels and mine don't. I wonder what consititudes a network
mappings drive label.

I did see some WinSDK calls relating to volume information, but I don't
see any in the .Net Framework. I am wondering if anyone know of any
calls above and beyond my sample code.

Jan 3 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Stephan Deibel | last post by:
Hi, O'Reilly Associates has agreed to print a second volume of Python Success Stories and I am looking for contributors of new stories. This booklet will showcase Python in the context of a...
6
by: E G | last post by:
Hi! I am having problems in designing a class. First, I have a base class that allocates a 3D data set and allows some other mathematical operations with it, something like this: template...
21
by: Michael Bierman | last post by:
Please forgive the simplicy of this question. I have the following code which attempts to determine the color of some text and set other text to match that color. It works fine in Firefox, but does...
1
by: Krazitchek | last post by:
Hi, i check all directories on a disk but an error occurs when i try to enter in the "System Volume Information" directory. Is there a way to "jump" this directory without to check the name of...
3
by: Jeff Gaines | last post by:
I am using the 'ManagementObject' to get the volume name of each drive on my PC. It works but it is a bottleneck. Is there an quicker way to get this information? I am using C# but am happy yo...
3
by: Jefe | last post by:
Hi group I'm trying to implement a console application which work just lie "Dir" instruction in MS-Dos prompt window so I need to display Volume Serial Number and also the free space, how can I...
0
by: geoffrey.slinker | last post by:
I have developed a new type of chart. It shows the relative volume for each price during an interval. http://home.att.net/~geoffrey.slinker/maverick/VolumeBars.html I am a Data Visualization...
8
by: martin | last post by:
how can we get volume information in vb.net
1
devonknows
by: devonknows | last post by:
I was wondering if any of you vb guru's can help me with this, im buildign a simple computer monitor that monitors vcertain aspects of the machine, page file usage, physcial memory, logical drive...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.