procedure TForm1.Button1Click(Sender: TObject);
var tmplist:TStringList;
    tmpstream:TFileStream;
begin
  tmplist:=TStringList.Create ;
  tmpstream:=TFileStream.Create('c:\sms.txt',fmOpenRead);
  tmpstream.Position:=0;
  tmplist.LoadFromStream(tmpstream);
  showmessage(inttostr(tmplist.Count ));
  tmplist.Free ;
  tmpstream.Free ;
end;

解决方案 »

  1.   

    function Read(var Buffer; Count: Longint): Longint; virtual; abstract;DescriptionEach descendant stream object defines a Read method that reads data from its particular storage medium (such as memory or a disk file).Read is used in cases where the number of bytes to read from the stream is not necessarily fixed. It attempts to read up to Count bytes into buffer and returns the number of bytes actually read.All the other data-reading methods of a stream (ReadBuffer, ReadComponent) call Read to do their actual reading.Introduces a pure virtual method for writing to the stream.function Write(const Buffer; Count: Longint): Longint; virtual; abstract;DescriptionEach descendant stream object defines a Write method that writes data to its particular storage medium (such as memory or a disk file). Write attempts to write up to Count bytes to Buffer, and returns the number of bytes actually written.All the other data-writing methods of a stream (WriteBuffer, WriteComponent) call Write to do their actual writing.
      

  2.   

    谢谢问题解决,给分了
    ---------------------
    procedure TForm2.SpeedButton1Click(Sender: TObject);
    var tmplist:TStringList;
        tmpstream:TFileStream;
    begin
      tmplist:=TStringList.Create ;
      if OpenDialog1.Execute then
         begin
         tmpstream:=TFileStream.Create(OpenDialog1.FileName,fmOpenRead);
         tmpstream.Position:=0;
         tmplist.LoadFromStream(tmpstream);
         showmessage(inttostr(tmplist.Count ));
         end;
      tmplist.Free ;
      tmpstream.Free ;
    end;