By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,276 Members | 1,951 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,276 IT Pros & Developers. It's quick & easy.

Logical Drive information

P: n/a
Hi,
After enumerating the logical drives, using GetLogicalDrives, I need to know
the Drive Types, ie. Floppy or Network.

Is it possible in C# to do this? Thanks in advance.

Alwin S.
Nov 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Al Sav schrieb:
After enumerating the logical drives, using GetLogicalDrives, I need to know the Drive Types, ie. Floppy or Network.

Is it possible in C# to do this? Thanks in advance.


..NET hasn't any build-in support for getting the drive type.
You can use the Win API function GetDriveType for doing that.

[DllImport("Kernel32.dll", CharSet=CharSet.Auto, SetLastError=true)]
public static extern uint GetDriveType(string lpRootPathName);

lpRootPathName is the root path of the drive

It returns the following:

public const uint DRIVE_UNKNOWN = 0 // unknow drive type
public const uint DRIVE_NO_ROOT_DIR = 1 // invalid root path was given
to the function
public const uint DRIVE_REMOVABLE = 2 // removeable drive like a floppy
public const uint DRIVE_FIXED = 3 // a fixed drive like a hard disk
public const uint DRIVE_REMOTE = 4 // a network drive
public const uint DRIVE_CDROM = 5 // a cd-rom drive
public const uint DRIVE_RAMDISK = 6 // a ram disk

Basti

Nov 16 '05 #2

P: n/a
Have you tried using WMI? I think the WMI class has this property already
(to save calls to API's).

Picho
"Al Sav" <Al***@discussions.microsoft.com> wrote in message
news:01**********************************@microsof t.com...
Hi,
After enumerating the logical drives, using GetLogicalDrives, I need to
know
the Drive Types, ie. Floppy or Network.

Is it possible in C# to do this? Thanks in advance.

Alwin S.

Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.