Inno Setup:列出目录中的所有文件名 [英] Inno Setup: List all file names in an directory

查看:199
本文介绍了Inno Setup:列出目录中的所有文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正在尝试列出目录中具有名称的所有文件,但无法执行.有什么办法列出目录中所有带有名称的文件?

Am trying to list all files with names in an directory, but unable to do. Is there any way to list all files with names in an directory?

谢谢.

推荐答案

以下脚本显示如何将指定目录的所有文件列出到TStrings集合中(在此示例中,在自定义页面的列表框中列出) :

The following script shows how to list all files of a specified directory into a TStrings collection (in this example listed in the list box on a custom page):

[Code]
procedure ListFiles(const Directory: string; Files: TStrings);
var
  FindRec: TFindRec;
begin
  Files.Clear;
  if FindFirst(ExpandConstant(Directory + '*'), FindRec) then
  try
    repeat
      if FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY = 0 then
        Files.Add(FindRec.Name);
    until
      not FindNext(FindRec);
  finally
    FindClose(FindRec);
  end;
end;

procedure InitializeWizard;
var
  CustomPage: TWizardPage;
  FileListBox: TNewListBox;
begin
  CustomPage := CreateCustomPage(wpWelcome, 'Caption', 'Description');
  FileListBox := TNewListBox.Create(WizardForm);
  FileListBox.Parent := CustomPage.Surface;
  FileListBox.Align := alClient;

  ListFiles('C:\SomeDirectory\', FileListBox.Items);
end;

这篇关于Inno Setup:列出目录中的所有文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆