Hoi,
also erstmal brauchst du diese Procedure (aus der
DP):
Delphi-Quellcode:
procedure SearchFileExt(const Dir, Ext: String; Files: TStrings);
var
Found: TSearchRec;
Sub: String;
i : Integer;
Dirs: TStrings; //Store sub-directories
Finished : Integer; //Result of Finding
begin
StopSearch := False;
Dirs := TStringList.Create;
Finished := FindFirst(Dir + '*.*', 63, Found);
while (Finished = 0) and not (StopSearch) do
begin
//Check if the name is valid.
if (Found.Name[1] <> '.') then
begin
//Check if file is a directory
if (Found.Attr and faDirectory = faDirectory) then
Dirs.Add(Dir + Found.Name) //Add to the directories list.
else
if Pos(UpperCase(Ext), UpperCase(Found.Name))>0 then
Files.Add(Dir + Found.Name);
end;
Finished := FindNext(Found);
end;
//end the search process.
FindClose(Found);
//Check if any sub-directories found
if not StopSearch then
for i := 0 to Dirs.Count - 1 do
//If sub-dirs then search agian ~>~>~> on and on, until it is done.
SearchFileExt(Dirs[i], Ext, Files);
//Clear the memories.
Dirs.Free;
end;
Sie such in dem Verzeichnis deiner Exe nach allen afs-Dateien.
Du benötigst noch eine Globale Var für die Procedure:
Dann machst du entweder in
FormCreate oder
ButtonXClick diese Procedure rein:
Delphi-Quellcode:
procedure TForm1.Button2Click(Sender: TObject);
var
i,x:integer;
files,asffile: TStringList;
begin
Files := TStringList.Create;
SearchFileExt(ExtractFilepath(Application.Exename) + '\', '.afs', Files);
for i := 0 to files.Count-1 do
begin
asffile := TStringlist.Create;
//memo1.Lines.Add(files.Strings[i]); // war nur eine Hilfe
asffile.LoadFromFile(files.Strings[i]);
for x := 0 to asffile.Count-1 do
begin
asffile.Strings[x] := changeIP(asffile.Strings[x],edit1.Text);
end;
asffile.SaveToFile(files.Strings[i]);
asffile.Free;
end;
files.free;
end;
[Edit] Code bearbeitet siehe comment!