I want to know whether a drive is a cdrom, network, hdd, etc...
I think I did it a long time ago with APIs, but wondering if .NET has any methods to get information about this?
Printable View
I want to know whether a drive is a cdrom, network, hdd, etc...
I think I did it a long time ago with APIs, but wondering if .NET has any methods to get information about this?
use FSO (faster)
or use WMI
hmm can you explain a bit more? are you talking about the IO.FileSystemInfo class?I remember somethign about that nasty fso in vb6, but dunno about vb.netQuote:
Originally posted by kovan
use FSO (faster)
or use WMI
yep thats what i am refering to
File system Object
you can reference it in your project reference as Microsoft Runtime Scripting
it provides you with the classes you need for Drives to determine what type of a drive is certain letter.
you can accomlish this through WMI but WMI is a lot slower than FSO.
Stick with the API's...
VB Code:
Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Int32 Private Enum DriveTypes 'used with GetDriveType Unknown = 0 Invalid_or_Not_Mounted=1 'invalid path: eg no volume mounted Removable = 2 Fixed = 3 Remote = 4 CDROM = 5 RAMDisk = 6 End Enum 'in a click event or something Dim iDriveType = GetDriveType(myDrive) 'decide type of drive and display appropriate drive letter. Select Case iDriveType Case DriveTypes.CDROM 'cd Case DriveTypes.Fixed 'hard Case DriveTypes.Remote 'remote Case DriveTypes.Removable 'removable Case DriveTypes.RAMDisk 'ramdisk Case Else 'unkown
hehe thank you both of you:D
umm I like the idea of sticking with APIs as well. btw would using the FSO object create any compatibility problems?
The API was the recommend way from a Microsoft MVP, he also stated that a DriveInfo class would be included in the next release of the .Net framework:
http://www.dotnet247.com/247referenc...36/183112.aspx
Here's his sample:
http://dotnet.mvps.org/dotnet/code/f...tem/index.html