Is there a way to uniquely identify any storage media connected to a Windows PC in .NET?

I have been looking for a solution to this for several weeks. I am looking for a way in which I can uniquely identify any media connected to a Windows PC. Information carriers in particular. These can be internal hard drives, external hard drives, flash drives, SD cards, smartphone storage, etc. No optical media.

Basically, what I want to do is indicate some unique line that is tied to a specific storage device, so at any time when the storage device is connected again, regardless of the drive letter, it can be automatically detected.

Problems I encountered:

  • Not every storage device has a serial number.
  • When SD cards are accessible through a card reader, the information available through WMI through the ManagementObjectSearcher class refers to the card reader, not the media file.

There seem to be 4 basic properties that can return unique information, but not always. SerialNumber , Caption , PNPDeviceID , Signature

Of course, there must be SOMETHING that Windows does to track such storage devices. Any ideas?

+8
c # windows
source share
1 answer

Can you write on these media? If so, what about creating a file in the root directory containing the GUID and saving the link to that GUID in your application. As a GUID and guaranteed unique, you can use this file to uniquely identify the volume.

+2
source share

All Articles