I try to use the FindFirstFile() and FindNextFile() function. Yet, 
something are going wrong. I cant read the ffd.cFileName. It display 
the name as "0012 FC64".

The coding is as below:

#include <iostream>
#include <windows.h>
#include <tchar.h>
using namespace std;

void EnumerateFolderFS(LPCTSTR path)
{
   WIN32_FIND_DATA ffd; // file information struct
   HANDLE sh = FindFirstFile(path, &ffd);
   if(INVALID_HANDLE_VALUE == sh) 
   {
           return; // not a proper path i guess
   }

   
   // enumerate all items; NOTE: FindFirstFile has already got info 
for an item
   do {
      cout << ffd.cFileName << endl;
      cout << "Type = " << ( (ffd.dwFileAttributes & 
FILE_ATTRIBUTE_DIRECTORY)
                             ? "dir\n" : "file\n" );
      cout << "Size = " << ffd.nFileSizeLow << "\n\n";
   } while (FindNextFile(sh, &ffd));


   FindClose(sh);
}

int main()
{
        EnumerateFolderFS(_TEXT("C:\\Program Files\\Microsoft Visual 
Studio 8\\VC\\include\\*.h"));

        cin.get();
        return 0;
}

Reply via email to