0

This question seems similar to some I found here, but I didn't understand the replies they got. I have a VB process that will sometimes be writing to an external hard drive. This drive may be plugged in, unplugged, plugged in again etc. I have a literal for the drive, but as I understand it there's a chance it could have a different drive letter assigned each time it's plugged in. My question is simply this: Is there a way I can use the drive name or label (I'm not sure what the correct term in) to find the drive letter assigned, or, better yet, write to the drive using only the name/label? For the time being, we'll assume the drive is plugged in when the process runs so we don't have to check for that. I don't have a lot of experience in VB so please keep replies simple.

Ross from Brooklin
  • 293
  • 1
  • 5
  • 18
  • 1
    What kind of *drive* are we talking about? Is that a standard USB device? -- You can receive a notification when a device is added / removed from the System. To determine whether it's the one you care about, you can inspect, e.g., its Serial Number (or verify it contains specific content in one specific partition, in case of a storage device) -- Can you link some of the Q&A you found that doesn't answer your question in some way? – Jimi Nov 20 '22 at 20:06
  • 1
    For example, see [How do I get information about recently connected USB device?](https://stackoverflow.com/a/54298316/7444103) and a possible *nosy* companion: [Get the serial number of USB storage devices in .Net Core 2.1](https://stackoverflow.com/a/51806262/7444103) – Jimi Nov 20 '22 at 20:11

1 Answers1

0

I found that by scrolling through the drive info for all active drives, I can see if one has the correct VolumeLabel. If it does, then I just take the name for that drive. This also provides an easy way to check whether or not the drive is plugged in - if it isn't then the variable that I created to store the name and initialized to null will still be empty.

Ross from Brooklin
  • 293
  • 1
  • 5
  • 18