Click here to Skip to main content
Sign Up to vote bad
good
See more: C++/MFC
Hi.
 
I am trying to find a way to check whether a drive is valid on the hard disk. Ex: if I name a network drive to T: is there an API I can use to check that T: is valid (maybe the network is down?).
 
I would appreciate any hint or help on this.
 
Thanks.
 
Stan the man
Posted 26 Sep '12 - 7:08


2 solutions

hi
I don't know the api but you can do this with CFile.
save an empty file to the drive, if it success it will returns 1 else it returns 0
 
CFile f;
if(f.Open(drive_path+_T("\\\\a.txt"),CFile::modeCreate|CFile::modewrite)){
   f.Close();
   //drive_path is valid drive
}else{
   //drive_path isnot valid
}
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 393
1 OriginalGriff 335
2 Arun Vasu 315
3 Maciej Los 238
4 Aarti Meswania 180
0 Sergey Alexandrovich Kryukov 9,680
1 OriginalGriff 7,539
2 CPallini 4,018
3 Rohan Leuva 3,362
4 Maciej Los 2,951


Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 29 Oct 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid