Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking paths and drives.

Status
Not open for further replies.

WilliamGS

Programmer
Jan 21, 2004
54
PE
Hello. How can I verify if a path is correct? only if it is correct, no matter if it doesn't exist; also, how can I verify if a drive exits?
I have a dialog where the user puts a path (example: P:\PROJECT1\DRAWINGS), and I have to verify it: the drive must exits y and it must be correct.

I am using VC++ 6.00.

Thanks in advance.

William GS.
 
>how can I verify if a drive exits?

Any directory (including the root) has at least a . (dot) ...
[/code]
bool driveExist(TCHAR d)
{
CString drivePath;
drivePath = CString(d)+":\\*.*"; // i.e X:\*.*
WIN32_FIND_DATA fd;
HANDLE hFind;
hFind = FindFirstFile(drivePath,&fd);
bool result = false;
if (hFind != INVALID_HANDLE_VALUE)
{
result = true;
FindClose(hFind);
}
return result;
}
[/code]

>I have a dialog where the user puts a path ...
1) If directiry exists - its valid
2) Else, if you can create the directory - its valid
3) Else, it's not valid.

(is there a point in specifying a non-existant directory?)


/Per
[sub]
"It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure."[/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top