在Delphi中,遍历文件夹可以使用以下方法:
uses
System.IOUtils;
procedure TraverseFolder(const AFolder: string);
var
Files: TArray<string>;
FileName: string;
begin
Files := TDirectory.GetFiles(AFolder);
for FileName in Files do
begin
// Do something with the file
ShowMessage(FileName);
end;
end;
uses
System.IOUtils;
procedure TraverseFolder(const AFolder: string);
var
Directories: TArray<string>;
SubFolder: string;
begin
Directories := TDirectory.GetDirectories(AFolder);
for SubFolder in Directories do
begin
// Do something with the subfolder
ShowMessage(SubFolder);
end;
end;
这些方法可以帮助您遍历文件夹及其内容,并对其进行操作。