title: C++ - Having problems with a simple example of FindFirstFile
body: <p>I'm using the following ultra-super-mega simple code to list all the files in a direcory (Windows 8.1, Visual Studio Express 2013, C++):</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;sys/stat.h&gt;
  
  #include &lt;limits&gt;
  #include &lt;cstdio&gt;
  #include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;bitset&gt;
  
  #include &lt;windows.h&gt;
  #include &lt;tchar.h&gt;
  #include &lt;stdio.h&gt;
  
  
  using namespace std;
  
  
  void get_file_list(string DATA_DIR)
  {
      HANDLE hFind;
      WIN32_FIND_DATA data;
  
      hFind = FindFirstFile(LPCWSTR(DATA_DIR.c_str()), &amp;data);
  
      if (hFind != INVALID_HANDLE_VALUE) {
          do {
              printf("%s\n", data.cFileName);
          } while (FindNextFile(hFind, &amp;data));
          FindClose(hFind);
      }
  }
  
  int main(int argc, char** argv)
  {
  
      string DATA_DIR = "D:\\drobpox\\Dropbox\\BinaryDescriptors\\LFW\\DATA\\*.*";
      //string DATA_DIR = "c:\\Users\\GilLevi\\Downloads\\GraphsSURF\\GraphsSURF\\bark\\*.jpg";
      string OUT_DIR = "D:\\drobpox\\Dropbox\\BinaryDescriptors\\LFW\\LATCH_TXT_FILES\\LATCH8";
  
  
      get_file_list(DATA_DIR);
  
  }
  </code></pre>
  
  <p>However, I "hFind" always equals "INVALID_HANDLE_VALUE". I double checked the path and tried various different paths. </p>
  
  <p>Might the reason be that I'm running a 64bit application and using WIN32_FIND_DATA ?</p>
  
  <p>Thanks in advance,
  Gil</p>