Delphi-PRAXiS
Seite 4 von 4   « Erste     234   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Delphi Newbie!!! Wie kann ich eine Text-Datei auslesen? (https://www.delphipraxis.net/10632-newbie-wie-kann-ich-eine-text-datei-auslesen.html)

RomanK 24. Okt 2003 15:41

Re: Newbie!!! Wie kann ich eine Text-Datei auslesen?
 
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:
Delphi-Quellcode:
var
   StopSearch: Boolean;
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!

mlspider 24. Okt 2003 16:39

Re: Newbie!!! Wie kann ich eine Text-Datei auslesen?
 
Oh Gott. Na hoffentlich bekomme ich das hin.

Erst mal danke.


Alle Zeitangaben in WEZ +1. Es ist jetzt 14:40 Uhr.
Seite 4 von 4   « Erste     234   

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz