473,404 Members | 2,178 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,404 software developers and data experts.

Valid Drives

This should be easy, but I can not figure it out, how does one get a list of
current drives on the computer?

Thanks,
David
Dec 11 '05 #1
4 960
David,

For 1.x or for 2.0.

In 2.0 there is a method for that.

http://msdn2.microsoft.com/en-us/lib...em.drives.aspx

For 1.x you need some WMI code.
There are a lof of samples made for this, this is one I have saved, which
is looking at the code obviously not made by me.

\\\
Dim searcher As New ManagementObjectSearcher _
("SELECT * FROM Win32_LogicalDisk")
Dim ManObjOp As ManagementObject
If searcher.Get.Count > 1 Then
For Each ManObjOp In searcher.Get
Dim win32 As String = "Win32_LogicalDisk='" &
ManObjOp("Name").ToString & "'"
Dim ManObjLogD As New ManagementObject(win32)
For Each diskProperty As PropertyData In
ManObjLogD.Properties
If Not diskProperty.Value Is Nothing Then
Console.WriteLine _
("{0} = {1}", diskProperty.Name, diskProperty.Value)
End If
Next
Next
End If
///

I hope this helps,

Cor
"D Miller" <de**********@yahoo.com> schreef in bericht
This should be easy, but I can not figure it out, how does one get a list
of current drives on the computer?

Thanks,
David

Dec 11 '05 #2
Hi,

In addition to Cor's comments. You can use
environment.getlogicaldrives to get a list of drives on the system. You
will not get any additional information like type or size. Use the wmi for
that in the framework 1.1 or 1.0

For Each strDrive As String In Environment.GetLogicalDrives
Debug.WriteLine(strDrive)
Next
Ken
----------------------------
"D Miller" <de**********@yahoo.com> wrote in message
news:eT*****************@newsread3.news.pas.earthl ink.net...
This should be easy, but I can not figure it out, how does one get a list
of current drives on the computer?

Thanks,
David

Dec 11 '05 #3
"D Miller" <de**********@yahoo.com> schrieb:
This should be easy, but I can not figure it out, how does one get a list
of current drives on the computer?


'System.Environment.GetLogicalDrives'. This method cannot be used to check
whether or not a drive contains a disk.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Dec 11 '05 #4
Thanks for the command, is there any reason why it does not report back all
of network drives defined?

Thanks,
David
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:OF**************@TK2MSFTNGP10.phx.gbl...
Hi,

In addition to Cor's comments. You can use
environment.getlogicaldrives to get a list of drives on the system. You
will not get any additional information like type or size. Use the wmi
for that in the framework 1.1 or 1.0

For Each strDrive As String In Environment.GetLogicalDrives
Debug.WriteLine(strDrive)
Next
Ken
----------------------------
"D Miller" <de**********@yahoo.com> wrote in message
news:eT*****************@newsread3.news.pas.earthl ink.net...
This should be easy, but I can not figure it out, how does one get a list
of current drives on the computer?

Thanks,
David


Dec 12 '05 #5

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

Similar topics

1
by: Travis L. Alltop | last post by:
All, To make a long story short, we are swapping out the "knock-off" drives that the NA purchased on E-Bay in one of our production SQL Servers (SQL Server 2000 Enterprise) this weekend for...
36
by: Ron Johnson | last post by:
http://hardware.devchannel.org/hardwarechannel/03/10/20/1953249.shtml?tid=20&tid=38&tid=49 -- ----------------------------------------------------------------- Ron Johnson, Jr....
7
by: Eric.Jones | last post by:
I've encountered a strange error with loading delimited files from a Samba (SMB) network drive, has anyone else seen this before? (Platform: WinXP Pro, UDB PE 8015, level 02060106, SAMPLE db) ...
3
by: Flix | last post by:
I need to detect the root directories of the installed hard disks (es: C:, D:, E:, etc.). I'm not interested in cd drives. I know that there is a way (a bit slow, if I remeber) to retrive all the...
0
by: Dennis | last post by:
I have tried to use the IWshRuntimeLibrary and ManagementObjectSearcher("SELECT * FROM Win32_LogicalDisk") to get all Logical Drives, Mapped Network Drives, Shared Folders and Shared Drives with...
4
by: David A. Osborn | last post by:
Is there a way to check if a drive is valid, both when you know the drive letter and when you want to get a listing of all valid drive letters?
2
by: ImOk | last post by:
WHen I run this under Windows I get the Count of drives but then I get an error message on the Reset() when I try to enumerate. Does this work for anyone? $fs = new...
8
by: Salad | last post by:
I was asked to get my daughter a flash drive. She needs to use it to copy files to it so she can transfer the files at school to her desktop at home. I've never used one but I figure some of...
14
AnuSumesh
by: AnuSumesh | last post by:
Hi all, I am writing one application using c# in which firstly I m getting impersonating the user and then i want to retrieve mapped Drives. But issue is when I am calling method in following...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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.