Question

Like the title says, I have a C++ program and the user passes in an argument. I want to validate whether the argument passed is a valid DOS/Windows drive letter (i.e. C:. D:. E:) and that the drive exists on the system. How do I do this?

Was it helpful?

Solution

You can get the type of a drive with GetDriveType() - which also tells you if a drive doesn't exist or isn't availble

Or the 'correct' way is to enumerate through all the drives

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top