with TStringList.Create do try
  LoadFromFile('c:\temp.txt');
  if Count > 0 then
    ShowMessage(Strings[0]); //第一行
finally
  Free;
end;

解决方案 »

  1.   

    with TStringList.Create do try
      LoadFromFile('c:\temp.txt');
      if Count > 0 then
        ShowMessage(Strings[0]); //第一行
    finally
      Free;
    end;
      

  2.   

    with TStringList.Create do try
      LoadFromFile('c:\temp.txt');
      if Count > 0 then
        ShowMessage(Strings[0]); //第一行
    finally
      Free;
    end;
      

  3.   

    var myfile : textfile;
       s : string[20];
    begin
      assignfile(myfile,'aa.txt');
      reset(myfile);
      readln(myfile,s);
      memo1.lines.add(s);
      closefile(myfile)
    end;
      

  4.   

    还可以用打开对话框收文件信息。
    读文件一行,在VB里有个SELSTART 和SELLENGTH 属性 DLEPHI里我没用过,它可以自动选取一端字符。
      

  5.   

    var
      sl : TStringList;
    begin
      sl := TStringList.Create; 
    with sl do 
    begin
     try
      LoadFromFile('filename');
      if Count > 0 then
        ShowMessage(Strings[0]); //第一行
     finally
      Free;
     end;
    end;
      

  6.   

    var
      TxtFile:TTextFile;
      Str:String;
    begin
      AssignFile(TxtFile,'C:\a.txt');
      Reset(TxtFile);
      Readln(TxtFile,Str);
      ShowMessage(Str);
      CloseFile(TxtFile);
    end;