无法让DelTree在Inno Setup中删除文件夹 [英] Can't get DelTree to delete a folder in Inno Setup
问题描述
我有一个过程DeleteTransferFolder
,在安装过程中使用Inno Setup中的BeforeInstall调用了该过程.
I have a procedure DeleteTransferFolder
which is called during the install using BeforeInstall in Inno Setup.
我知道调用该过程是因为我有几个显示的MsgBox消息.但是DelTree不会删除指定的文件夹和子文件夹.
I know the procedure is called because I have a couple of MsgBox messages that show. But the DelTree does not delete the specified folder and sub-folders.
有什么想法吗?
procedure DeleteTransferFolder();
begin
MsgBox('DeleteTransferFolder 1', mbInformation, MB_OK);
if (FileExists ('{userdesktop}\RemedyNotes 1.0\RemedyNotes Old.remno')) then
DelTree(ExpandConstant('{userdesktop}\RemedyNotes 1.0'), True, True, True);
MsgBox('DeleteTransferFolder 2', mbInformation, MB_OK);
end;
推荐答案
在FileExists行中缺少ExpandConstant调用,因此它返回false,因此不会调用DelTree.
You're missing the ExpandConstant call in the FileExists line, so it is returning false and thus the DelTree is not called.
之所以显示第二个MsgBox,是因为它不在条件if中(可能是由于缺少开始/结束对).
The second MsgBox is shown because it is out of the conditional if (maybe due to the lack of a begin/end pair).
因此,将您的代码更改为:
So, change your code to:
procedure DeleteTransferFolder();
begin
MsgBox('DeleteTransferFolder 1', mbInformation, MB_OK);
if (FileExists (ExpandConstant('{userdesktop}\RemedyNotes 1.0\RemedyNotes Old.remno'))) then
begin
DelTree(ExpandConstant('{userdesktop}\RemedyNotes 1.0'), True, True, True);
MsgBox('DeleteTransferFolder 2', mbInformation, MB_OK);
end;
end;
这篇关于无法让DelTree在Inno Setup中删除文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!