with TStringList.Create do try
LoadFromFile('c:\temp.txt');
if Count > 0 then
ShowMessage(Strings[0]); //第一行
finally
Free;
end;
LoadFromFile('c:\temp.txt');
if Count > 0 then
ShowMessage(Strings[0]); //第一行
finally
Free;
end;
解决方案 »
- 如何将XMl文件的数据导入数据库(sql/FB)?(十万火急需源代码,在线等待)
- 使用format函数出错
- 请问SQLConnection处理事务的详细用法?请给出详细代码!
- 如何给dxdbgrid动态添加列
- 缅怀9.18先烈!抵制日货!日本人说的一句让中国人心寒的话!
- ADO出错!
- 怪问题。我编了一个函数在listview中显示数据库中的数据,可总是多了一空行为何?救命!
- 关于MDI的问题
- 怎样使TeeChart划出平滑的线条?
- 怎么判断table到了记录的最后一条?
- 各位同行。给我个Delphi 6.0的sp2吧。我急用的。
- 我的TListView控件的checkboxes选择了true,即在每一行前加复选框,如何使点击某一行的checkbox,行焦点也随之变为这一行?
LoadFromFile('c:\temp.txt');
if Count > 0 then
ShowMessage(Strings[0]); //第一行
finally
Free;
end;
LoadFromFile('c:\temp.txt');
if Count > 0 then
ShowMessage(Strings[0]); //第一行
finally
Free;
end;
s : string[20];
begin
assignfile(myfile,'aa.txt');
reset(myfile);
readln(myfile,s);
memo1.lines.add(s);
closefile(myfile)
end;
读文件一行,在VB里有个SELSTART 和SELLENGTH 属性 DLEPHI里我没用过,它可以自动选取一端字符。
sl : TStringList;
begin
sl := TStringList.Create;
with sl do
begin
try
LoadFromFile('filename');
if Count > 0 then
ShowMessage(Strings[0]); //第一行
finally
Free;
end;
end;
TxtFile:TTextFile;
Str:String;
begin
AssignFile(TxtFile,'C:\a.txt');
Reset(TxtFile);
Readln(TxtFile,Str);
ShowMessage(Str);
CloseFile(TxtFile);
end;