PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 1.00 average.

How to differentiate between USB flash drive and floppy

 
 
Kjetil Viggen
Guest
Posts: n/a
 
      17th Aug 2009
I am currently using the System.IO.DriveInfo class to go through the
available drives on the system:

var drives = System.IO.DriveInfo.GetDrives();
foreach (System.IO.DriveInfo drive in drives)
{
System.IO.DriveType type = drive.DriveType;
...
}

My problem is that I want to skip any floppy drives in this enumeration (Yes
- there are still systems with floppy drives out there...). However DriveType
does not help me do this. From the documentation on the DriveType enumeration:

" Removable:
The drive is a removable storage device, such as a floppy disk drive or a
USB flash drive."

WMI probably has some options to do differentiate between different
removable drive types, but my previous experience with WMI has shown severe
problems there when running as non-administrator users. So I am reluctant to
try this...

Another possible option is to just skip if drive letter is A: or B:, as
these are reserved for floppies. But the Windows Knowledge Base says:

"Drive letters A and B are reserved for floppy disk drives. However, if your
computer does not have a floppy disk drive, you can assign these letters to
removable drives."

So that is not exactly waterproof either...

How can I easily check if a given drive is a floppy drive or not?

Kjetil.

 
Reply With Quote
 
 
 
 
Kjetil Viggen
Guest
Posts: n/a
 
      17th Aug 2009


"Mark Rae [MVP]" wrote:

> I'm not even certain that WMI can help you unless there is actual media in
> the drive:
> http://msdn.microsoft.com/en-us/library/aa394173(VS.85).aspx


Did a quick WMI-test using Win32_LogicalDisk and without any floppy in the
drive:
Description: 3 1/2 Inch Floppy Drive
DeviceID: A:

This looks sort of promising, but can I trust that all floppy drives come up
with a description like this...?

> And what about a USB floppy...?


Well, I would certainly like to detect that as a floppy too, so for me it is
not sufficient just to see that a given drive letter represents a USB-device.

Kjetil

 
Reply With Quote
 
Kjetil Viggen
Guest
Posts: n/a
 
      17th Aug 2009

"Mark Rae [MVP]" wrote:
> There is, however, a dedicated WMI newsgroup
> (microsoft.public.dotnet.framework.wmi) where you will probably get a much
> better answer...


Thanks Mark, I'll try a post there and see what happens.

Kjetil.
 
Reply With Quote
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      18th Aug 2009
One of the problems with USB is how screwed up the standard is, IMO. I had
to use it to iterate through a device that took 8 serial ports into a single
USB. It may be easier for drives. There are some Windows calls you can
PInvoke for drives. I am not sure how much info you can get.
Win32_LogicalDiskToPartition and Win32_DiskDrive are a couple that might be
useful. Sometime you end up having to search the registry for more
information; I did with the Serial device.

I am not sure about flash drives and USB floppies, but I did find the serial
port devices were rather specific in how they were set up in the Registry.
Unfortunately, I had to know a bit too much about the device and alter my
config files for each one. I would assume USB drives are easier, but I
cannot guarantee it. Good luck on this one.

Peace and Grace,

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

********************************************************
| Think outside the box! |
********************************************************

"Kjetil Viggen" <(E-Mail Removed)> wrote in message
news:5ED1D574-89A9-4F5B-93BE-(E-Mail Removed)...
> I am currently using the System.IO.DriveInfo class to go through the
> available drives on the system:
>
> var drives = System.IO.DriveInfo.GetDrives();
> foreach (System.IO.DriveInfo drive in drives)
> {
> System.IO.DriveType type = drive.DriveType;
> ...
> }
>
> My problem is that I want to skip any floppy drives in this enumeration
> (Yes
> - there are still systems with floppy drives out there...). However
> DriveType
> does not help me do this. From the documentation on the DriveType
> enumeration:
>
> " Removable:
> The drive is a removable storage device, such as a floppy disk drive or a
> USB flash drive."
>
> WMI probably has some options to do differentiate between different
> removable drive types, but my previous experience with WMI has shown
> severe
> problems there when running as non-administrator users. So I am reluctant
> to
> try this...
>
> Another possible option is to just skip if drive letter is A: or B:, as
> these are reserved for floppies. But the Windows Knowledge Base says:
>
> "Drive letters A and B are reserved for floppy disk drives. However, if
> your
> computer does not have a floppy disk drive, you can assign these letters
> to
> removable drives."
>
> So that is not exactly waterproof either...
>
> How can I easily check if a given drive is a floppy drive or not?
>
> Kjetil.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pen drive/USB flash drive showing as floppy disk Mark Bates Windows Vista General Discussion 0 24th Mar 2008 07:27 PM
Flash drive/floppy drive scare ;) :) Skybuck Flying DIY PC 8 13th Nov 2006 06:51 PM
Floppy and Flash Drive No Longer Work Nick Cellino Windows XP New Users 6 5th Apr 2006 02:58 AM
Floppy Drive and Flash Drive Problem Nick Cellino Windows XP Help 1 24th Dec 2004 01:27 PM
floppy drive and usb pocket flash drive problem Alastair Windows XP Hardware 0 14th Jul 2003 09:44 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:08 PM.