Results 1 to 7 of 7

Thread: how can I figure out the "type" of a drive?

  1. #1

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    how can I figure out the "type" of a drive?

    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?
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  2. #2

  3. #3

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Originally posted by kovan
    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.net
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  4. #4
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,539
    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.

  5. #5
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Stick with the API's...
    VB Code:
    1. Private Declare Function GetDriveType Lib "kernel32" Alias
    2. "GetDriveTypeA" (ByVal nDrive As String) As Int32
    3.  
    4. Private Enum DriveTypes 'used with GetDriveType
    5. Unknown = 0
    6. Invalid_or_Not_Mounted=1 'invalid path: eg no volume mounted
    7. Removable = 2
    8. Fixed = 3
    9. Remote = 4
    10. CDROM = 5
    11. RAMDisk = 6
    12. End Enum
    13.  
    14. 'in a click event or something
    15. Dim iDriveType = GetDriveType(myDrive)
    16. 'decide type of drive and display appropriate drive letter.
    17. Select Case iDriveType
    18. Case DriveTypes.CDROM
    19. 'cd
    20. Case DriveTypes.Fixed
    21. 'hard
    22. Case DriveTypes.Remote
    23. 'remote
    24. Case DriveTypes.Removable
    25. 'removable
    26. Case DriveTypes.RAMDisk
    27. 'ramdisk
    28. Case Else
    29. 'unkown

  6. #6

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    hehe thank you both of you
    umm I like the idea of sticking with APIs as well. btw would using the FSO object create any compatibility problems?
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  7. #7
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width