list :TStringList;list:=TStringList.Create;
list.LoadFromFile("c:\abc.dat");
list[n-1] 就是第n行内容

解决方案 »

  1.   

    var
     mytextfile:textfile;
    s:string[255];
    i:integer;
    j:integer;
    begin
    assinfile(mytextfile,'mytextfile.txt');
    reset(mytextfile);
    try
      while not eof (mytextfile) do 
     begin
          readln(mytextfile,s,j)
    memo1.lines.add(s+inttostr(j));
    end;
    finally
     closefile(mytextfile);
    end;
    end;
      

  2.   

    以上两位的代码都可以,lwk_hlj的程序里只完成了读取文件的功能,定位的语句与第一位的差不多:
    memo1.lines[I -1]--第i行记录
      

  3.   

    用流来处理会很方便的:)
    var
    f:tfilestream;                         +--------------可能拼错了,你还是查查帮助吧
    s:array[1..255] of char;               |
    begin                                  \/
    f:=tfilestream.create('c:\abc.txt',fmonlywrite);
    f.read(s,255);
    ...处理过程
    f.free;
    end;
    要还有什么问题的话Mailto:[email protected]
      

  4.   

    对了
    我忘说了
    要是想到下一行的话
    还要在f.read(s,255);前加一行
    f.seek(n*255,0);
      

  5.   

    回复人: kuchong(苦虫) (2001-9-16 18:29:58)  得0分 
    用流来处理会很方便的:)
    var
    f:tfilestream;                        
    s:array[1..255] of char;              
    begin                                  
    f:=tfilestream.create('c:\abc.txt',fmOpenWrite);
    f.seek(n*255,soFromBeginning)
    f.read(s,255);
    ...处理过程
    f.free;
    end;
    要还有什么问题的话Mailto:[email protected]  
      

  6.   

    总结:
     方法1: 流
     方法2:Tstrings;
     方法3:文件操作。
      

  7.   

    用流来处理会很方便的:)抱歉我打错了
    var
    f:tfilestream;                        
    s:array[1..255] of char;              
    begin                                  
    f:=tfilestream.create('c:\abc.txt',fmOpenReadWrite);
    f.seek(n*255,soFromBeginning)
    f.read(s,255);
    ...处理过程
    f.free;
    end;
    要还有什么问题的话Mailto:[email protected]