procedure TForm1.Button1Click(Sender: TObject);
var
  onelist: Tstringlist;
  l: integer;
  aaa, tempstr: string;
begin
  onelist := tstringlist.Create;
  onelist.LoadFromFile('c:\zz.txt');
  tempstr := onelist.text;
  i:= length(tempstr);这里不准确
  onelist.Free;
  aaa:=  IntToStr(i);
  showmessage(aaa);
end;end.

解决方案 »

  1.   

    改为
    I:=length(WideString(tempstr));
      

  2.   

    var
      FindFileData: TWin32FindData;
      SearchHandle: THandle;
      FileLength: Dword;
      highsize:Dword;
    begin
      SearchHandle:= findfirstfile('e:\hl.rar',findfiledata);
      Filelength:=getfilesize(SearchHandle,@highsize);
      showmessage(inttostr(highsize));end;
      

  3.   

    这么麻烦?
    FileSize直接返回文件大小
      

  4.   

    var
      Tmpf: file of Byte;
      MyFileSize :integer;
    begin
      AssignFile(Tmpf,'c:\zz.txt');
      Reset(Tmpf);
      MyFileSize :=FileSize(Tmpf);
      CloseFile(Tmpf);
    end;------------------------------------------------
    在错的时间遇见错的人 是一种伤痛 
    在错的时间遇见对的人 是一种遗憾 
    在对的时间遇见错的人 是一种心伤 
    只有在对的时间遇见对的人才是一种幸福
      

  5.   

    引用 Sysutilsfunction FileSize(var F): Integer;DescriptionCall FileSize to determine the size of the file specified by the file variable F. To use FileSize, the file must be open. If the file is empty, FileSize(F) returns 0.
      

  6.   

    上面Linux2001(恋人不如自恋)说的对,但我要在操作中将内存中的文本改变,故要得到改变后的大小,
    procedure TForm1.Button1Click(Sender: TObject);
    var
      onelist: Tstringlist;
      i: integer;
      aaa, tempstr: string;
    begin
      onelist := tstringlist.Create;
      onelist.LoadFromFile('c:\zz.txt');
      tempstr := onelist.text;
      //在这里对tempstr 进行其它操作,代码太长省略
      i:= length(tempstr);这里不准确
      onelist.Free;
      aaa:=  IntToStr(i);
      showmessage(aaa);
    end;
      

  7.   

    FileSize()就能得到文件大小啊,文件最后如果有回车换行符的,再FileSize()的大小后加2就OK了。
      

  8.   

    onelist := tstringlist.Create;
      onelist.LoadFromFile('c:\zz.txt');
      i := 0;
      tempstr:='';
      for l := (onelist.Count - 1) downto 0 do
     begin
         tempstr:= onelist.Strings[l];//关键是字符串里包含回车换行就可能造成不准确
        i := i + length(tempstr);
      end;
      aaa := IntToStr(i);
      showmessage(aaa);
      onelist.free;
      

  9.   

    是不是这句出了问题tempstr:= onelist.Strings[l];
    TStringList装入文件时将回车换行符舍掉了.