title: Error Copying DBF/MDX files
body: <p>I use the following code to copy dbf/mdx files from one folder to another:</p>
  
  <pre><code>procedure TfrmMain.MyCopyFile(S1, S2: string);
  begin
     if not FileExists(S2) then
        CopyFile(PCHAR(S1), PCHAR(S2), true)
     else
        if Application.MessageBox(PCHAR('Overwrite existing file ' + S2 + '?'), 'File exists in folder',MB_YESNO + MB_DEFBUTTON1) = IDYES
            then CopyFile(PCHAR(S1), PCHAR(S2), false)
  end;
  </code></pre>
  
  <p>The code works fine when table name stays the same.  </p>
  
  <p>If I change the name of the table:</p>
  
  <pre><code>    MyCopyFile(CurPath + '\orders.dbf', NewPath + '\ordly.dbf');
      MyCopyFile(CurPath + '\orders.mdx', NewPath + '\ordly.mdx');
  </code></pre>
  
  <p>When I try to open <strong>ordly.dbf</strong> I get an error message:   </p>
  
  <blockquote>
    <p>Corrupt table/index header.<br>
     File: C:\DATA\2011\ORDLY.MDX</p>
  </blockquote>