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

More FSO Functioality that doesnt apear in System.IO

Using the FileSystemObject I can, at runtime find out which drive letter is asigned to the CD Rom Drive

Dim Fso As New Scripting.FileSystemObject
For Each Drive As Scripting.Drive In Fso.Drives
If Drive.DriveType = Scripting.DriveTypeConst.CDRom Then
MsgBox("Your CD Rom drive is: " & Drive.Path)
Exit For
End If
Next

But I cannot find a way to get this info out of the System.IO namespace

Dim objDir As System.IO.DirectoryInfo
For Each s As String In System.IO.Directory.GetLogicalDrives()
objDir = New System.IO.DirectoryInfo(s)
'Cant get the drive type from the DirectoryInfo Object
Next

I would prefer not to use the FileSystemObject if I can avoid it.
Please could someone point me in the right direction.

Ben
Jul 21 '05 #1
4 2306
"Ben Reese" <Be******@discussions.microsoft.com> schreef in bericht
news:1A**********************************@microsof t.com...
Using the FileSystemObject I can, at runtime find out which drive letter is asigned to the CD Rom Drive
Dim Fso As New Scripting.FileSystemObject
For Each Drive As Scripting.Drive In Fso.Drives
If Drive.DriveType = Scripting.DriveTypeConst.CDRom Then
MsgBox("Your CD Rom drive is: " & Drive.Path)
Exit For
End If
Next

But I cannot find a way to get this info out of the System.IO namespace

Dim objDir As System.IO.DirectoryInfo
For Each s As String In System.IO.Directory.GetLogicalDrives()
objDir = New System.IO.DirectoryInfo(s)
'Cant get the drive type from the DirectoryInfo Object
Next

I would prefer not to use the FileSystemObject if I can avoid it.
Please could someone point me in the right direction.

Ben


WMI has all the functionality now :
ManagementObjectSearcher query = new ManagementObjectSearcher("SELECT * From
Win32_LogicalDisk ");
ManagementObjectCollection queryCollection = query.Get();

foreach ( ManagementObject mo in queryCollection)
{
switch (int.Parse( mo["DriveType"].ToString()))
{
case 2: //removable drives
break;
case 3: //Local drives
break;
case 4: //Network drives
break;
case 5: //CD rom drives
break;
}
}
HTH

Yves
Jul 21 '05 #2
Thanks Yves this looks good

but where can I find a list of valid "PropertyValues" for the ManagementObject?

"phoenix" wrote:
"Ben Reese" <Be******@discussions.microsoft.com> schreef in bericht
news:1A**********************************@microsof t.com...
Using the FileSystemObject I can, at runtime find out which drive letter

is asigned to the CD Rom Drive

Dim Fso As New Scripting.FileSystemObject
For Each Drive As Scripting.Drive In Fso.Drives
If Drive.DriveType = Scripting.DriveTypeConst.CDRom Then
MsgBox("Your CD Rom drive is: " & Drive.Path)
Exit For
End If
Next

But I cannot find a way to get this info out of the System.IO namespace

Dim objDir As System.IO.DirectoryInfo
For Each s As String In System.IO.Directory.GetLogicalDrives()
objDir = New System.IO.DirectoryInfo(s)
'Cant get the drive type from the DirectoryInfo Object
Next

I would prefer not to use the FileSystemObject if I can avoid it.
Please could someone point me in the right direction.

Ben


WMI has all the functionality now :
ManagementObjectSearcher query = new ManagementObjectSearcher("SELECT * From
Win32_LogicalDisk ");
ManagementObjectCollection queryCollection = query.Get();

foreach ( ManagementObject mo in queryCollection)
{
switch (int.Parse( mo["DriveType"].ToString()))
{
case 2: //removable drives
break;
case 3: //Local drives
break;
case 4: //Network drives
break;
case 5: //CD rom drives
break;
}
}
HTH

Yves

Jul 21 '05 #3
Also

Is there no Enumeration that maps to the "DriveType"

Ben

"phoenix" wrote:
"Ben Reese" <Be******@discussions.microsoft.com> schreef in bericht
news:1A**********************************@microsof t.com...
Using the FileSystemObject I can, at runtime find out which drive letter

is asigned to the CD Rom Drive

Dim Fso As New Scripting.FileSystemObject
For Each Drive As Scripting.Drive In Fso.Drives
If Drive.DriveType = Scripting.DriveTypeConst.CDRom Then
MsgBox("Your CD Rom drive is: " & Drive.Path)
Exit For
End If
Next

But I cannot find a way to get this info out of the System.IO namespace

Dim objDir As System.IO.DirectoryInfo
For Each s As String In System.IO.Directory.GetLogicalDrives()
objDir = New System.IO.DirectoryInfo(s)
'Cant get the drive type from the DirectoryInfo Object
Next

I would prefer not to use the FileSystemObject if I can avoid it.
Please could someone point me in the right direction.

Ben


WMI has all the functionality now :
ManagementObjectSearcher query = new ManagementObjectSearcher("SELECT * From
Win32_LogicalDisk ");
ManagementObjectCollection queryCollection = query.Get();

foreach ( ManagementObject mo in queryCollection)
{
switch (int.Parse( mo["DriveType"].ToString()))
{
case 2: //removable drives
break;
case 3: //Local drives
break;
case 4: //Network drives
break;
case 5: //CD rom drives
break;
}
}
HTH

Yves

Jul 21 '05 #4
http://msdn.microsoft.com/library/de...ogicaldisk.asp

and similar pages offer an overview of all properties. Also clicking on the
different properties on that page will give you the corresponding enums. I
don't know if you can get them directly from inside C# though.

HTH

Yves

"Ben Reese" <Be******@discussions.microsoft.com> schreef in bericht
news:51**********************************@microsof t.com...
Thanks Yves this looks good

but where can I find a list of valid "PropertyValues" for the ManagementObject?
"phoenix" wrote:
"Ben Reese" <Be******@discussions.microsoft.com> schreef in bericht
news:1A**********************************@microsof t.com...
Using the FileSystemObject I can, at runtime find out which drive letter
is asigned to the CD Rom Drive

Dim Fso As New Scripting.FileSystemObject
For Each Drive As Scripting.Drive In Fso.Drives
If Drive.DriveType = Scripting.DriveTypeConst.CDRom Then
MsgBox("Your CD Rom drive is: " & Drive.Path)
Exit For
End If
Next

But I cannot find a way to get this info out of the System.IO
namespace
Dim objDir As System.IO.DirectoryInfo
For Each s As String In System.IO.Directory.GetLogicalDrives()
objDir = New System.IO.DirectoryInfo(s)
'Cant get the drive type from the DirectoryInfo Object
Next

I would prefer not to use the FileSystemObject if I can avoid it.
Please could someone point me in the right direction.

Ben


WMI has all the functionality now :
ManagementObjectSearcher query = new ManagementObjectSearcher("SELECT *

From Win32_LogicalDisk ");
ManagementObjectCollection queryCollection = query.Get();

foreach ( ManagementObject mo in queryCollection)
{
switch (int.Parse( mo["DriveType"].ToString()))
{
case 2: //removable drives
break;
case 3: //Local drives
break;
case 4: //Network drives
break;
case 5: //CD rom drives
break;
}
}
HTH

Yves

Jul 21 '05 #5

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

Similar topics

8
by: Paulo Pinto | last post by:
Hi, I have already several XSLT stylesheets that make use of <xslt:include> "command". Now I wanted to make them a bit more modular but I'm stuck. I want to take out the generated HTML code...
40
by: Greg G | last post by:
http://risky-biz.com/new/risky.html I finally got DSL service recently, but I haven't forgotten the agony of waiting for the 64th image to load before I can see ANYTHING on a page. So I will...
1
by: Hermit Dave | last post by:
Hello folks, Attaching some code from one of my pages... the paging on this page used to work just fine.... when i click next it doesnt even come anywhere near the DataGrid1_PageIndexChanged...
11
by: Simon | last post by:
Hi all As I'm sure is common knowledge the version of IIS included in XP Pro is limited in that you can only create 1 website in the IIS snap in. As an ASP.net developer this is a pain in the...
6
by: dee | last post by:
Hi In web.config I have to the following: <configuration> <system.web> <customErrors defaultRedirect="error.htm" mode="On" /> </system.web> </configuration>
4
by: Ben Reese | last post by:
Using the FileSystemObject I can, at runtime find out which drive letter is asigned to the CD Rom Drive Dim Fso As New Scripting.FileSystemObject For Each Drive As Scripting.Drive In Fso.Drives...
1
by: Arfeen | last post by:
Hi All, I need help again ..... I have an asp.net web page which I hit using the "HTTP POST" method. My ASP.NET page is a basic hello world example with the following code: private void...
151
by: istillshine | last post by:
There are many languages around: C++, JAVA, PASCAL, and so on. I tried to learn C++ and JAVA, but ended up criticizing them. Is it because C was my first programming language? I like C...
11
by: pgfdbug | last post by:
Below is the code for the program that runs my firehouses alerting system. It reads packets that come to our printer and gives us an audible alert on what piece is due. The two issuse I have with...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.