是不是有函数可以直接从一个文件中读出字符串呀,或者有没有别的办法?

解决方案 »

  1.   

    基本所有文本控件都有loadfromfield属性从文本中读取内容。
    好像是这个方法我也记不清了你再试一下。
      

  2.   


    assignfile(f,文件名)
    reset(f)seek(f,i)
    read(f,a)
      

  3.   

    procedure TForm1.BitBtn6Click(Sender: TObject);
    var
      FileName : TextFile;
      Str,Tmp : String;
      TStrList : TStringList;
      i,k : Integer;
    begin
      TStrList := TStringList.Create;
      TStrList.Clear;
      if not (FileExists(GetNameDir(Application.ExeName)+'xuanhao.txt')) then
      begin
        Application.MessageBox('xuanhao.txt文件不存在,请先转出TXT文件','提示',MB_OK+MB_ICONSTOP);
        Exit;
      end;
      AssignFile(FileName,GetNameDir(Application.ExeName) + 'xuanhao.txt');
      Reset(FileName);
      Readln(FileName,Str);
      CloseFile(FileName);
      if Str <> '' then
      begin
        i := pos(',',str);
        while i > 0 do
        begin
          Tmp := copy(Str,1,i - 1);
          TStrList.Add(Tmp);
          Str := copy(Str,i + 1,length(Str)-i);
          i := pos(',',Str);
        end;
        if Str <> '' then
        begin
          TStrList.Add(Str);
        end;
      end;
      

  4.   

    以前也做过一个类似的,我是逐个读取字符,希望对你有帮助 
        AssignFile(fF1,文件名称);
        ReSet(fF1);
        while not EOF(fF1) do
        begin
          READ(fF1,cTmpChar);
          逐个读取字符进行操作
        end;