473,387 Members | 1,575 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,387 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 2308
"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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.