Open htcfreek opened 6 months ago
Tagging subscribers to this area: @dotnet/area-system-io See info in area-owners.md if you want to be subscribed.
Author: | htcfreek |
---|---|
Assignees: | - |
Labels: | `area-System.IO`, `untriaged` |
Milestone: | - |
Retrieving the physical type of a drive is highly complicated because you cross the boundary between a logical volume and a physical device. A logical device can span multiple physical devices.
In windows, DeviceIoControl()
with IOCTL_STORAGE_QUERY_PROPERTY
returns the information for property id StorageDeviceSeekPenaltyProperty
in DEVICE_SEEK_PENALTY_DESCRIPTOR::IncursSeekPenalty
which might be the closest to SSD vs HDD. But you need the correct volume handle.
I'm not sure if this information fits into the runtime because of all the edge cases to consider. In general, DriveInfo
already is not reliable because it doesn't handle most multi-span or non-drive-letter volumes correctly. In a nutshell, any directory can be a volume mount point. Which means, my volume C:\
can be an SSD, but I can also mount a volume at C:\External\Drive-123
to an HDD. It would just return wrong results. If you use virtual volumes that combine multiple other volumes (like stacking), then every directory can reside on a different volume. There are so many edge cases to consider.
Personally, I don't think it's worth it. This goes too deep into system information and would require a specific library that is designed to handle all this. Any user would expect a 100% correct result and not a "95% right but can be wrong". Especially if you try to optimize of an SSD drive and the runtime says it's an SSD when it's actually an HDD.
The
DriveType
property ofSystem.IO.FileSyste.DriveInfo
currently does supportCD
andRemovable
. But for internal drives it always saysfixed
. It can not decide between SSD and HDD.Implementation suggestion
A new property that not brakes the existing one called
PhysicalMedia
with the following supported values:Unknown
Optical
(ODD) for CD, DVD, ...Floppy
(FDD)SSD
HDD
Network Share
Virtual
for vhd, vhdx, ...Raid
for JBOD, Software RaidRemovable USB
(And maybe more.)