更新时间:2023-12-02 10:34:10
System.IOUtils
添加到您的使用条款。然后,您可以用code TPath
和 TDirectory
是这样的:
Add System.IOUtils
to your uses clause. You can then use code TPath
and TDirectory
something like this:
uses
System.IOUtils, System.Types;
procedure TForm1.Button1Click(Sender: TObject);
var
FileList: TStringDynArray;
DocDir: string;
s: string;
begin
Memo1.Lines.Clear;
DocDir := TPath.GetDocumentsPath;
FileList := TDirectory.GetFiles(DocDir);
for s in FileList do
Memo1.Lines.Add(s);
end;