问题:将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;
一担将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;
我是2003+delphi7.0+vclzip3.04
你可以试一下低版本的,比如vclzip2.23
----------------
我以前也用过vclzip3.04的,脱离DELPHI的环境,解压出来的文件名为:XXX,当我用回2.23,就没有问题啦
大家帮忙下