天哪,我发现这年头人都很zhuai
我说的这个可是最混的办法。
帮到底了,如果可以就请我吃饭,不行再想办法。[xx(]
procedure TForm1.SearchFiles(CurrentPath : AnsiString; FileNames: TStringList);
var
sr : TSearchRec;
iFound : Integer;
s: string;
begin
iFound := FindFirst(CurrentPath + '*.*', faAnyFile, sr);
while iFound=0 do
begin
if ((sr.Attr and faDirectory) = 0)and(sr.Name<>'.')and(sr.Name<>'..') then
begin
s := sr.Name;
FileNames.Add(s);
end;
iFound := FindNext(sr);
end;
FindClose(sr);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
FileNames: TStringList;
buf: TStringList;
i: Integer;
begin
FileNames := TStringList.Create;
SearchFiles(YourPath, FileNames); //你的路径
if FileNames.Count > 0 then
begin
for i := 0 to FileNames.Count-1 do
begin
if pos(YourPartName, FileNames) > 0 then //你的部分字符串,能确定只有一个符合条件么?
begin
try
buf := TStringList.Create;
buf.LoadFromFile(FileNames);
//这里你操作这个buf就可以了
finally
buf.Free;
end;
end;
end;
end;
FileNames.Free;
end;