In this example:
Code File:
Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, stdctrls; Type tform1 = Class (tform) memo1: tmemo; memo2: tmemo; button1: tbutton; Procedure button1click (Sender: tobject); Procedure formcreate (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} {function for reading hexadecimal characters} function readfiletohex (filename: string): string; var BS: tbytesstream; I: integer; begin result: = ''; if not fileexists (filename) Then exit; BS: = tbytesstream. create; BS. loadfromfile (filename); for I: = 0 to BS. size-1 do result: = Result + format ('%. 2x ', [BS. bytes [I]); BS. free; end; {test} procedure tform1.button1click (Sender: tobject); const filepath = 'C: \ temp \ text.txt '; begin memo1.lines. savetofile (filepath); memo2.text: = readfiletohex (filepath); end; Procedure tform1.formcreate (Sender: tobject); begin button1.caption: = 'save and read the hexadecimal format (note that the 0d 0a read is a line break) '; end.
Form file:
Object form1: tform1 left = 0 Top = 0 caption = 'form1' clientheight = 149 clientwidth = 339 color = clbtnface font. charset = default_charset font. color = clwindowtext font. height =-11 font. name = 'tahoma 'font. style = [] oldcreateorder = false oncreate = formcreate pixelsperinch = 96 textheight = 13 object memo1: tmemo left = 0 Top = 0 width = 160 Height = 124 align = alleft lines. strings = ('memo1') scrollbars = ssvertical taborder = 0 end object memo2: tmemo left = 179 Top = 0 width = 160 Height = 124 align = alright lines. strings = ('memo2') scrollbars = ssvertical taborder = 1 end object button1: tbutton left = 0 Top = 124 width = 339 Height = 25 align = Albottom caption = 'button1' taborder = 2 onclick = button1click endend