Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

[WMI]: is possible retreive the name of a removable device?

Status
Not open for further replies.

tadan

Programmer
Apr 19, 2004
39
0
0
IT
Hi all.
I have the necessity to retreive (if exists) the 'name' (od the 'unique id') for a removable device, such as the usb memory stick (I would like to know the exact name of the device to have the possibility to remember this and using to rw with an implementation of permission rule).
I've tried to get infos using System.Environment, and in the particular using the query 'select * from win32_logicaldisk' but I have only the logicalId, Name, Size, Freespace, DriveType.

Sorry for my english but I think you understand all the same.

Best Regards
Francesco Cabigliera





Francesco Cabigliera "Tadan"
----------------------------
Italiano Amateur Radio Station
----------- IW3IDS ---------
On Echolink - APRS Active
 
I think USB memory sticks show up as removable drives, so you might be able to use the following to get the name:
Code:
DriveInfo[] drives = DriveInfo.GetDrives();

foreach (DriveInfo di in drives)
{
	if (di.DriveType == DriveType.Removable) Console.WriteLine(di.VolumeLabel);
}
 
Dear SHelton,
thank you for you're post!
I've tried you're code and wokrs fine, but I've discovered that if I re-format the usb stick my volume number change (!!!!!).
Is there a way to capture another unique info (such as the product id+ serial number+manufacturer)?

thanks again :)

Best Regards

Francesco Cabigliera




Francesco Cabigliera "Tadan"
----------------------------
Italiano Amateur Radio Station
----------- IW3IDS ---------
On Echolink - APRS Active
 
I don't know of any managed classes that will allow you to get at that info, you'll probably need to look at calling some API's.

Sorry I can't be more help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top