なのはなぜか"抽象的にエラー"と呼TJclCompressArchive.圧縮?
-
21-09-2019 - |
質問
私は、以下のコードはいつも失敗し、"抽象的にエラー:
arch := TJclCompressArchive.Create(GetDesktop + 'Support.7z');
try
with arch do
begin
if FindFirst('*.log', faAnyFile, sr) = 0 then
begin
repeat
AddFile(ExtractFileName(sr.Name),sr.Name);
until FindNext(sr) <> 0;
FindClose(sr);
end;
Compress; //this line throws the error
end;
finally
arch.free;
end;
しかし、常に取得する場合にはエラーと圧縮.そのアイデアかしかったので、良かった間違いので、これから
解決
ダウンロードいただけましてお伝えできるようなJclCompressArchiveの作成などで arch := TJcl7zCompressArchive.Create...
の代わりにJclCompressArchive.Create().
また、"クラス階層のJclCompression.pas:
TJclCompressionArchive
|
|-- TJclCompressArchive
| |
| |-- TJclSevenzipCompressArchive
| |
| |-- TJclZipCompressArchive handled by sevenzip ...
| |-- TJclBZ2CompressArchive handled by sevenzip ...
| |-- TJcl7zCompressArchive handled by sevenzip ...
| |-- TJclTarCompressArchive handled by sevenzip ...
| |-- TJclGZipCompressArchive handled by sevenzip ...
| |-- TJclXzCompressArchive handled by sevenzip ...
更新
と思い、正しい使用StackOverflowされている追加の質問以降、アップデート後では全く異なる質問です。
なぜだかよくわかりませんだ鋳造TJclCompressArchiveにAddFile()圧縮(),そのために働くのかぶり
const
FILENAME = 'Support.7z';
var
archiveclass: TJCLUpdateArchiveClass;
arch: TJclUpdateArchive;
sr: TSearchRec;
begin
archiveclass := GetArchiveFormats.FindUpdateFormat(FILENAME);
if not Assigned(archiveclass) then
raise Exception.Create('Could not determine the Format of ' + FILENAME);
arch := archiveclass.Create(FILENAME);
try
// if FileExists(FILENAME) then // if you want to add any new files,
// arch.ListFiles; // in addition to what is already there
if FindFirst('*.pas', faAnyFile, sr) = 0 then
begin
repeat
arch.AddFile(ExtractFileName(sr.Name),sr.Name);
until FindNext(sr) <> 0;
FindClose(sr);
end;
arch.Compress;
finally
arch.free;
end;
end;
所属していません StackOverflow