在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;
這些方法可以幫助您遍歷文件夾及其內容,并對其進行操作。