Inno Setup - Check if multiple folders exist

◇◆丶佛笑我妖孽 提交于 2019-12-08 04:16:22

In general, there's no better way than calling DirExists for each folder:

if DirExists('C:\path1') or
   DirExists('C:\path2') or
   DirExists('C:\path3') then
begin
  { ... }
end;

Though, when processing a set of files/folders, it's advisable to have their list stored in some container (like TStringList or array of string), to allow their (repeated) bulk-processing. You already have that (Dirs: TStringList) from my solution to your other question.

var
  Dirs: TStringList;
begin
  Dirs := TStringList.Create();
  Dirs.Add('C:\path1');
  Dirs.Add('C:\path2');
  Dirs.Add('C:\path2');
end;
function AnyDirExists(Dirs: TStringList): Boolean;
var
  I: Integer;
begin
  for I := 0 to Dirs.Count - 1 do
  begin
    if DirExists(Dirs[I]) then
    begin
      Result := True;
      Exit;
    end;
  end;

  Result := False;
end;

But I know from your other question, that you map all the paths to checkboxes. Hence, all you need to do, is to check, if there's any checkbox:

if CheckListBox.Items.Count > 0 then
begin
  UninstallProgressForm.InnerNotebook.ActivePage := UninstallConfigssPage;

  { ... }

  if UninstallProgressForm.ShowModal = mrCancel then Abort;

  { ... }

  UninstallProgressForm.InnerNotebook.ActivePage := UninstallProgressForm.InstallingPage;
end;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!