removable drive seen in debbugger although i filter it.

Dani_S 3,106 Reputation points


i used this code and i see removable drive in debugger, why?

I used mac.

DriveInfo[] drives = DriveInfo.GetDrives();

drives = drives.Where(drive=> drive.DriveType != DriveType.Removable && drive.DriveType != DriveType.CDRom).ToArray();


A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,077 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce ( 59,471 Reputation points

    DriveInfo.GetDrives() is returning mount information. It list all known mounts (physical or image). the unix call statfs() is used to get the volume information for the mount point.

    the .Name and .RootDirectory will return the mount point. typically "/System/Volumes/<volume name>". but the mount point can be anywhere. a user may create "/System/Volumes/Usb" folder and mount usb drives there. The IOS simulator disk images are mounted under "/Library/Developer/CoreSimulator/Volumes/". would not expect:

    drives = drives.Where(drive=> drive.Name == "//").ToArray();

    to return any values as "//" is not a typical path or mount point.

    the .DriveType is a mapping of the unix file system type. for example "iso", "cd9660" are mapped to DriveType.CDRom. see code:

    note: because the file system type is used to determine DriveType.Removable, it is not reliable. a fat formatted usb volume would be .Removable, but an apfs formatted usb volume would not.