问题:将delphi软件打开,,不需要打开源文件,以前编译出来的EXE文件对11.txt能正常压缩恢复...
一担将delphi关掉,能压缩,但是恢复时候11.txt是空文件...是不是VCLZIP控件还得注册什么的?
做了好多天了,郁闷一下procedure TdmMain.backup(const fn: string);/////fn为压缩备份后的文件名*.zip
//备份数据
  ///////////////////////////////////////////
  procedure zipfn(dbfn: string);
  //压缩指定文件
  var
    Stream: TFileStream;
  begin
    Stream := TFileStream.Create(frmMain.gExecuteFilePath + 'db\' + dbfn, fmOpenRead);
    try
      zip.ZipFromStream(Stream, dbfn);
    finally
      Stream.Free;
    end;
  end;
begin
  zip.ZipName := fn;
  zipfn('11.txt');
  zip.SaveModifiedZipFile;
end;///////////////////////////////////////////
procedure TdmMain.restore(const fn: string);fn为恢复数据的源的文件名*.zip
//恢复数据
  ///////////////////////////////////////////
  procedure unzipfn(dbfn: string);
  //解压到指定文件
  var
    Stream: TFileStream;
  begin
    Stream := TFileStream.Create(frmMain.gExecuteFilePath + 'db\temp.tmp',
      fmCreate);
    try
      unzip.UnZipToStream(Stream, dbfn);
    finally
      Stream.Free;
    end;
    Windows.CopyFile(PChar(frmMain.gExecuteFilePath + 'db\temp.tmp'),
      PChar(frmMain.gExecuteFilePath + 'db\' + dbfn), false);
    ShowMessage(frmMain.gExecuteFilePath + 'db\' + dbfn);
  end;
begin
  unzip.ZipName := fn;
  try
    unzip.ReadZip;      unzipfn('11.txt'); 
  finally
    unzip.ClearZip;
    if FileExists(frmMain.gExecuteFilePath + 'db\temp.tmp') then
      Windows.DeleteFile(PChar(frmMain.gExecuteFilePath + 'db\temp.tmp'));
  end;
end;

解决方案 »

  1.   

    谢谢帮忙 ...难道还是我这边的环境问题???vclzip是不是还有要注册这么一说??
    我是2003+delphi7.0+vclzip3.04
      

  2.   

    呵呵,vclzip的版本问题
    你可以试一下低版本的,比如vclzip2.23
    ----------------
    我以前也用过vclzip3.04的,脱离DELPHI的环境,解压出来的文件名为:XXX,当我用回2.23,就没有问题啦
      

  3.   

    哦 压缩时候有时候压缩成的ZIP文件和上次同名时候,,ZIP不是重写,而是把上次的11.TXT改成XXX文件.然后再往ZIP灌一个11.TXT文件进去..好象是不能覆盖的问题
    大家帮忙下
      

  4.   

    压缩和解压都用一个VCLZip组件!!!
      

  5.   

    关于vclzip使用的说明 太少了,有的请贡献一下