建议用TSTRINGLIST,直接用READFROMFILE
解决方案 »
- JJ进来~~~
- 求MySQLDAC 2.0以上的D7可用版本,最好是FS!
- 如何将窗体置顶就像消息框一样必须关闭才能进行下一步操作!
- 如何用DELPHI将WORD文档写入SQL SERVER库?
- 算是难题吧!关于dbchart控件中用不同颜色画线
- DELPHI中如何使用MFC编写的动态库里的类对象???
- 郁闷了!救命啊!
- 怎样使dbgrid随form大小变化而变化,up有分!!!欢迎捧场!!!(在先等待)
- 帮新手了!!!!帮者有分
- 怎么设置treeview中每个分支中的背景色?
- 小小问题,居然没有人知道,难道没有高人了吗?
- 初学者问题(如果把listview的viewstyle=vsreport时,怎样定位第n行,第n列?有什么?
Line0 : string;
f: TStringList;
begin
f := TStringList.Create;
try
f.LoadFromFile('d:\filename.txt');
Line0 := f.lines[0];
finally
f.free;
end;
end;
Line0 := f.Strings[0];
var
S: string;
F:TexTFile;
begin
if OpenDialog1.Execute then
begin
AssignFile(F, OpenDialog1.FileName);
ReSet(F);
while not Eof(F) do
begin
Readln(F, S);
ShowMessage(S);
end;
CloseFile(F);
end;
end;end.
var
Temp:AnsiString;
MF:TextFile;
begin
AssignFile(MF,'data.dat');
Reset(MF);
Readln(MF,temp);
end;
变量temp是从文件DATA.DAT中读取出一行;
var
S: string;
F:TexTFile;
begin
if OpenDialog1.Execute then
begin
AssignFile(F, OpenDialog1.FileName);
ReSet(F);
while not Eof(F) do
begin
Readln(F, S);
ShowMessage(S);
end;
CloseFile(F);
end;
end;
procedure TForm1.WrtFileClick(Sender: TObject);
var
T:TextFile;
Path:String;
begin
Path:=GetCurrentDir+'\a.txt';
AssignFile(T,Path);
ReWrite(T);
Write(T,'aa');
WriteLn(T);
CloseFile(T);
end;procedure TForm1.OpnFileClick(Sender: TObject);
var
T:TextFile;
Path,Str:String;
begin
Path:=GetCurrentDir+'\a.txt';
AssignFile(T,Path);
if FileExists(Path) then
Reset(T)
else
Exit;
Read(T,Str);
ShowMessage(Str);
CloseFile(T);
end;