为什么我会收到“抽象错误”当调用 TJclCompressArchive.Compress 时?
我有以下代码,总是因“抽象错误”而失败:
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;
但是,在尝试压缩时我总是收到该错误。关于我在这里做错了什么有什么想法吗?
I have the following code that always fails with an "Abstract Error":
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;
However, I always get that error when trying to Compress. Any ideas on what I'm doing wrong here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信你必须告诉它要创建哪种类型的 JclCompressArchive,例如给它
arch := TJcl7zCompressArchive.Create...
而不是 JclCompressArchive.Create()。如果您查看 JclCompression.pas 的“类层次结构”部分:
更新
我认为使用 StackOverflow 的正确方法是添加一个新问题,因为更新后,这是一个完全不同的问题。
我不知道你为什么要强制转换为 TJclCompressArchive 到 AddFile() 和 Compress(),它似乎无需强制转换就对我有用
I believe you have to tell it which kind of JclCompressArchive to create, such as give it
arch := TJcl7zCompressArchive.Create...
instead of JclCompressArchive.Create().If you look at the "Class Hierarchy" section of JclCompression.pas:
Update
I think the proper way to use StackOverflow would have been to add a new question, since after the update, it's a completely different question.
I don't know why you're casting to TJclCompressArchive to AddFile() and Compress(), it seems to work for me without the casts