it *should* work, never done this exact thing before, but done stuff that checks to see if the file is there before it does anything, so i bet itd work
It will not work, infile != NULL allways.
There are a lot of ways to do it.
1)
#include <windows.h>
if(GetFileAttributes( PathName) == -1 ) {
//File not exists or no access - what is?
unsigned long dwerr = GetLastError();
if(dwerr == ERROR_SUCCESS || dwerr == ERROR_FILE_NOT_FOUND || dwerr == ERROR_PATH_NOT_FOUND || dwerr == ERROR_BAD_NETPATH) {
//File really not exists!
}
else {
//No access
}
}
2)
#include <io.h>
...
if(access(PathName, 0) == -1) {
//File not exists
}
3)
#include <stdio.h>
....
FILE * fl = fopen(PathName,"rb"
if ( fl == NULL) {
//File not exists or no read access
}
else
fclose( fl); //Close handle
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.