Sign in to follow this  
Alex Swinney

Win32 Check for file?

Recommended Posts

Alex Swinney    236
Is there any way to check if a file exists WITHOUT creating it in Win32 or c++? I've tried C++, I don't get anything except empty files that were created when I tried to check their existence. Thanks

Share this post


Link to post
Share on other sites
SiCrane    11839
In C++ a std::ifstream shouldn't create a new file if it doesn't exist. Otherwise in Win32, you should be able to use CreateFile() with the OPEN_EXISTING flag.

Share this post


Link to post
Share on other sites
kaysik    382
I'm sure fopen() also has a flag that turns off the auto creation as well ... google will show you the way!

Edit: Infact if you open a file for reading it should never be created if it doesn't exist - it should just fail!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this