i tried to open a directory in my local computer but the function opendir() always
return error "can not open the directory "
i send the following directory names
- "."
- c:\\src\\
and alot of directories witch r exist in my PC
please i need heeeeeeeeeeeelp
Note : my windows is 7 and i work in c++ win32 console application in .net2008
Hi
I Think .Net should have it's own library or class, I am not sure but it shlud be some thing like FindFirstFile and FindNextFile , to handle directroy and file system input out issues. Why do you use opendir ?
[code]"Please use code tags"[/code]
Again, ¿what does perror() say?
1 2 3 4 5 6 7
#include <stdio.h>
DIR *dir = opendir(path);
if(dir){
//...
}
else perror("Cannot open directory");
man opendir wrote:
The opendir() and fdopendir() functions return a pointer to the directory stream. On error, NULL is returned, and errno is set appropriately.
man perror wrote:
The routine perror() produces a message on the standard error output, describing the last error encountered during a call to a system or library function
(...)The error number is taken from the external variable errno, which is set when errors occur but not cleared when successful calls are made.
opendir/readdir/closedir are POSIX system calls. As you're using Windows, you should be using Windows system calls FindFirstFile/FindNextFile/FindClose.
Alternatively, you can use a cross-platform solution (like Boost).
There is no dirent.h supplied with the Microsoft C/C++ compilers.