开发者

Problems in deleting a Folder during the uninstallation with Inno Setup

I begin by saying that i am new in using Inno setup and i am sorry if this is a dumb question. I am trying to delete a folder with all it's sub-folders and files during the uninstallation of an application. The specific folder is created in My Documents when the application runes for the first time. For deleting it i am using the "Delltree" function:

    procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var Ceva: integer;
begin
  case CurUninstallStep of
    usUninstall:
      begin
        MsgBox('CurUninstallStepChanged:' #13#13 'Uninstall is about to start.', mbInformation, MB_OK)
         end;
    usPostUninstall:
      begin
            Ceva := MsgBox('CurUninstallStepChanged:' #13#13 'Do you want to delete the folder ?.', mbConfirmation, MB_YESNO)
        if Ceva = idYES  then
        DelTree('{userdocs}\myfolder', True, True, True);           
      end;
开发者_StackOverflow社区  end;

For some reason the "{userdocs}" constant appear not to be working. If i put the exact path to the folder "DelTree('C:\Users\myuser\Documents\myfolder', True, True, True); " everything is working fine.


When you use a constant in code, you need to use the ExpandConstant function. So your Deltree command should be:

DelTree('ExpandConstant({userdocs})\myfolder', True, True, True);

Alternatively, have you looked at the [UninstallDelete] section? It can delete a directory and files at uninstall time without the need for code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜