Hello, I've been trying to get a list of files from given directory in C++ (with win32)
but i encountered some weird problems
my output is:
and I'm certain that it's a folder, not a file...
even when I do
I'm still getting "Pictures"!
anything wrong with the code?
why am i not getting an actual file name?
wondering if it's my WCHAR to char* cast...(ugly isnt it?)
P.S.
is there a quick way to find the number of files in a directory?
(I am using VC++ 2008 with Windows XP Pro)
Thank you in advance,
Netwatcher.
but i encountered some weird problems
Code:
//test snippet
#include <windows.h>
#include <stdio.h>
#include <iostream>
int main()
{
//find file data
WIN32_FIND_DATA findFileData;
HANDLE hFind = FindFirstFile((LPCSTR)"C:\\Documents and
Settings\\Me\\Desktop\\Pictures", &findFileData);
//print it out
std::cout <<"Files in dir:" <<std::endl;
std::cout <<(char*)&findFileData.cFileName<<std::endl; //problem might be here
char pause;
std::cin>> pause;
return 0;
}
Code:
Files in dir
Pictures
even when I do
Code:
FindNextFile (hFind, &findFileData)
anything wrong with the code?
why am i not getting an actual file name?
wondering if it's my WCHAR to char* cast...(ugly isnt it?)
P.S.
is there a quick way to find the number of files in a directory?
(I am using VC++ 2008 with Windows XP Pro)
Thank you in advance,
Netwatcher.
Comment