Question and Answer Database FAQ717D.txt inserting contents of a file at current position in TMemo Category :VCL Platform :All Product :All 32 bit Question: How can I insert the contents of a file at the current position in a TMemo component? Answer: Use a TMemoryStream to read the file, then use the TMemo's SetSelTextBuf() method to insert the text; var TheMStream : TMemoryStream; Zero : char; begin TheMStream := TMemoryStream.Create; TheMStream.LoadFromFile('C:\AUTOEXEC.BAT'); TheMStream.Seek(0, soFromEnd); //Null terminate the buffer! Zero := #0; TheMStream.Write(Zero, 1); TheMStream.Seek(0, soFromBeginning); Memo1.SetSelTextBuf(TheMStream.Memory); TheMStream.Free; end; 7/16/98 4:31:28 PM
Last Modified: 01-SEP-99