Check If A File Exists C Code Example
Example 1: c check if file exists
if( access( fname, F_OK ) == 0 ) { // file exists } else { // file doesn't exist }
Example 2: c check if file was created
int canCreateFile(char* path) { FILE* file = fopen(path, "w"); if(file) { fclose(file); return 1; } return 0; }
Comments
Post a Comment