发布网友 发布时间:2022-08-18 01:10
共1个回答
热心网友 时间:2023-11-06 03:32
先把txt文件里面的数据提取出来放在一个容器中,比如listbox中,然后对里面的数据进行对比 var TempAllUser:Tstringlist; mstrm:TMemoryStream; i,j:integer; begin mstrm:=TMemoryStream.Create; try mstrm.LoadFromFile('文件路径'+'*.txt'); listbox1.items.add:=mstrm; finally mstrm.Free; end; for i:=0 to listbox1.count-1 do begin str1:=listbox1.items.strings[i]; for j:=i+1 to listbox1.count-1 do begin str2:=listbox1.items.strings[j]; if pos(str1,str2)>0 then listbox1.Items.Delete(j); end; end; TempAllUser:=Tstringlist.Create ; try for i:=0 to listbox1.count-1 do begin TempAllUser:=listbox1.items.strings[i]; TempAllUser.SaveToFile('文件路径'+'*.txt'); end; finally TempAllUser.Free ; end; end;