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 to see if files/directories exist 1

Status
Not open for further replies.

SmileeTiger

Programmer
Mar 13, 2000
200
US
I want to check to see if a file and a directory (which may be empty) exist. how would I do this?
 
These are brute force ideas, there's probably tidier ones...

The file is easy... try to open it readonly.

The directory is a little harder, but you could call one of the directory parsing routines such as findfirst with the same effect.

Remember to close the find and end your find correctly.

Rosalie Dieteman
 
use GetFileAttributes and include windows.h. If file or directory doesn't exist function returns an unsigned -1 (is FFFFFFFF) John Fill
1c.bmp


ivfmd@mail.md
 
Hi,
You can use of CFile for opening your path, then check the return value of CFile object ...
 
The CheckFileAttributes worked out great!

Thanks!
Smilee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top