Autor Beitrag
Us0R
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 37



BeitragVerfasst: So 24.04.05 19:49 
Hallo, kann man eine zB. *.txt Datei in einen TString laden?!


Moderiert von user profile iconraziel: Topic aus VCL (Visual Component Library) verschoben am So 24.04.2005 um 20:53
Tobias1
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 454

Win 98, XP Prof
D3 Prof, D2005 Prof
BeitragVerfasst: So 24.04.05 19:51 
Ich würde es mit Umweg machen erst in ein Memo oder Stringlist mit loadfromfile dann in ein String(s:=memo1.lines.text oder s:=stringlist1.text). Geht bestimmt auch einfacher

_________________
Auch das schlechteste Buch hat seine gute Seite: die letzte. (John Osborne)
Fabian W.
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: Sa 30.04.05 06:52 
@UsOR: Du hast oben 'ZB txt. Dateien' geschrieben, was für welche willst'de denn noch laden??
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Sa 30.04.05 15:01 
user profile iconUs0R hat folgendes geschrieben:
Hallo, kann man eine zB. *.txt Datei in einen TString laden?!

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
var
  S: String;
  Handle: Integer;
begin

  Handle := FileOpen(FileName, fmOpenRead);
  if Handle <> -1 then
  begin
    SetLength(S, FileSeek(Handle, 0, soFromEnd));
    FileSeek(Handle, 0, soFromBeginning);
    FileRead(Handle, S[1], Length(S));
    FileClose(Handle);
    ShowMessage(S);
  end;

end;

_________________
Ciao, Sprint.
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Sa 30.04.05 16:52 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
var
 SList: TStringList;
  MyString: String;
begin
  SList := TStringList.Create;
  SList.LoadFromFile('C:\MyDatei.txt');

  MyString := SList.Text;

  SList.Free;
end;


Ist einfacher.

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)