when i am including (#include in visual studio 2005) this headerfile it is showing the error as (fatal error C1083: Cannot open include file: 'dirent.h': No such file or directory) i am new to C++ can anyone please provide me the solution for this error?
A:
The error message says it all. The file does not exist or it is not in the correct directory. Check out this website. It includes a free implementation of dirent.h
.
hanno
2010-02-09 11:31:30
ya! its working thanx for providing me the site.
SHIVA KUMAR
2010-02-09 14:19:03
So, how about closing this question?
hanno
2010-02-09 16:40:12
Questions don't get close unless they're not real questions for some reason. They should get an accepted answer though, @SHIVA.
Bill
2010-02-10 16:45:16
A:
Try including just dir.h
and if that doesn't work try io.h
#include <errno.h>
#include <iostream>
#include <io.h>
#include <time.h>
using namespace std;
bool canDelete(int timeCreate);
int main() {
struct _finddata_t data;
int handle;
handle = _findfirst("test.txt", &data);
if(handle == -1) {
exit(1);
}
if(canDelete(data.time_create)) {
cout << "Deleting file ...\n\n";
} else {
cout << "File ok.\n\n";
}
}
/**
* @param: the time in seconds that the file was created.
* @return: true if the file was created more than 7 days,
* false otherwise.
**/
bool canDelete(int time_create) {
time_t seconds = time(NULL);
int days = 7;
int max_time = 60 * 60 * 24 * days;
int time_passed = seconds - time_create;
if(time_passed > max_time) {
return true;
} else {
return false;
}
}
Pentium10
2010-02-09 11:32:43
+1
A:
You should add the directory where the file is located to the "additional include folders" in the Visual Studio project properties.
Paolo Tedesco
2010-02-09 11:32:51
+1
A:
The file dirent.h is not a C++ Standard header file. As you are on Windows, you probably want to use the FindFirstFile and related functions, declared in windows.h
anon
2010-02-09 11:36:40