title: SHFileOperation error 87
body: <p>I am trying to copy the contents of the A drive into folder C:\test\disk1. Folder disk1 already exists. The program compiles but when it runs I get error 87. I know error 87 has something to do with an invalid parameter but Im not sure where the problem lies. Has anyone any ideas?</p>
  
  <pre><code>#include &lt;Windows.h&gt;
  #include &lt;stdio.h&gt;
  
  int main(int argc, char ** argv)
  {
      const wchar_t *const sourceFile = L"A:\\";
      const wchar_t *const outputFile = L"C:\\test\\disk1";
  
      SHFILEOPSTRUCTW fileOperation;
      memset(&amp;fileOperation, 0, sizeof(SHFILEOPSTRUCTW));
  
      fileOperation.wFunc = FO_COPY;
      fileOperation.fFlags = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR |
                                 FOF_NOERRORUI | FOF_FILESONLY;
      fileOperation.pFrom = sourceFile;
      fileOperation.pTo = outputFile;
  
      int result = SHFileOperationW(&amp;fileOperation);
      if (result != 0)
      {
          printf("SHFileOperation Failure: Error%u\n", result);
          return 1;
      }
  
      memset(&amp;fileOperation, 0, sizeof(SHFILEOPSTRUCTW));
  
      printf("OK\n");
      return 0;
  }
  </code></pre>