我使用以下代码将 dbf/mdx 文件从一个文件夹复制到另一个文件夹:
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;
当表名保持不变时,代码可以正常工作。
如果我更改表的名称:
MyCopyFile(CurPath + '\orders.dbf', NewPath + '\ordly.dbf');
MyCopyFile(CurPath + '\orders.mdx', NewPath + '\ordly.mdx');
当我尝试打开ordly.dbf时,我收到一条错误消息:
损坏的表/索引头。
文件:C:\DATA\2011\ORDLY.MDX