473,407 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Logical Drive information

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
2 4915
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: muser | last post by:
Can anyone run this program through their compiler or if they can see a logical error please point it out. I have my tutor working on it at the moment but I would rather a less ambigious response...
0
by: chris6995 | last post by:
I'm looking for a way to programatically query for the association between a physical device (i.e. removable USB storage) and it's logical drive letter. I've gone through Win32_LogicalDisk,...
2
by: Marathoner | last post by:
I need to get the list of logical drive letters for mapped drives as well as the UNC or share name of the drive. I can obtain an array of the drive letters but it is the assiciated name that I...
1
by: benoit laude | last post by:
Hello, I want to compare the path of a file with a value in a database, to see if the file is the "good" file. It seems simple!! But it doesn't work if we create a logical drive on the client...
0
by: Nasiq Ali | last post by:
I have a logical drive which is mapped to a folder in a remote machine . Due to some secuirity reasons the drive can't be accessed from a C#/C++ program . Do Windows have any API which can be used...
1
by: teejayem | last post by:
Hi. Hopefully somebody out there will be able to help me! I am using VB.Net and I am trying to find out logical disk information. I would like to be able to find the drive letters of any...
1
by: PuzzleC | last post by:
Sorry, of my bad english language! I have wishes do getting a valid logical drive line using C or C++. no information about that. function _chdrive , _dos_setdrive be unfitness...
4
by: TyVi3t | last post by:
I have a hard drive that has 2 partitions. C: is logical and G: is primary. I want to make C: the primary. C: currently has the OS installed it. If I delete G: the computer will not boot up. Is...
0
by: dgrundel | last post by:
Hello, I've done some searching on this and the only way I can tell to get a list of logical drives and their type is using System.Management and querying Win32_LogicalDisk. While that does...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.