在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Memo1: TMemo; Button1: TButton; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); end; var Form1: TForm1; implementation {$R *.dfm} uses IOUtils, Types; const path = 'C:\Program Files\Embarcadero\RAD Studio\7.0'; //获取指定目录下有 Li 开头的文件 procedure TForm1.Button1Click(Sender: TObject); var files: TStringDynArray; str: string; begin files := TDirectory.GetFiles(path, 'Li*.*'); Memo1.Clear; for str in files do Memo1.Lines.Add(str); end; //获取指定目录及其子目录下文件名只有 3 个字母的 pas 文件 procedure TForm1.Button2Click(Sender: TObject); var files: TStringDynArray; str: string; begin files := TDirectory.GetFiles(path, '???.pas', TSearchOption.soAllDirectories); Memo1.Clear; for str in files do Memo1.Lines.Add(str); end; end. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论