3
votes

I have a procedure DeleteTransferFolder which is called during the install using BeforeInstall in Inno Setup.

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.

Any thoughts ?

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;
1

1 Answers

4
votes

You're missing the ExpandConstant call in the FileExists line, so it is returning false and thus the DelTree is not called.

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;