title: ERROR_INVALID_FUNCTION 1 (0x1)
body: <p>I'm having this weird error with my application that is supposed to copy files from a directory given from the command line to another directory. </p>
  
  <p>I'm using of course the three API functions; CreateFile, ReadFile, and WriteFile. I can't use the CopyFile API.</p>
  
  <p>Note that the compiler doesn't report any errors nor any warnings.</p>
  
  <pre><code>hFile1 = CreateFile(argv[1], GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, NULL); 
  
  hSearch = FindFirstFile((L"*.*"), &amp;hFind); 
  if (hSearch == INVALID_HANDLE_VALUE) { _tprintf(L"No files found.\n"); }
  
  do 
  {
    if (ReadFile(hFile1, Buffer, BUFSIZE, &amp;BytesRead, NULL))
    {
  
      cFile = WriteFile(hFile2, Buffer, BytesRead, &amp;BytesWritten, NULL);
      if (!cFile)
      {
        _tprintf(L"Couldn't copy file.\n");
      }
  
    }
  } while (BUFSIZE == BytesRead);
  </code></pre>