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?
Asked
Active
Viewed 3,639 times
1
-
1Even if the drive letter was valid you may not be able to access it for other reasons so you always wrap the call in a `try catch` block so if you get an exception I would presume the drive letter was duff or you didn't have permission to access it or some other error – EdChum Apr 10 '12 at 18:21
-
Perhaps this could help: http://stackoverflow.com/questions/2284110/get-a-list-of-the-available-drives-and-their-sizes – chris Apr 10 '12 at 18:22
1 Answers
5
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

Martin Beckett
- 94,801
- 28
- 188
- 263