<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>In my own code I use BlockRead/BlockWrite, but I'm wondering if
I've not seen this somewhere in RTL.<br>
</p>
<p><a moz-do-not-send="true"
href="https://github.com/jsuzineau/pascal_o_r_mapping/blob/TjsDataContexte/pascal_o_r_mapping/02_Units/uuStrings.pas">https://github.com/jsuzineau/pascal_o_r_mapping/blob/TjsDataContexte/pascal_o_r_mapping/02_Units/uuStrings.pas</a></p>
<pre>function String_from_File( _FileName: String): String;</pre>
<pre>var</pre>
<pre> F: File;</pre>
<pre> Longueur: Integer;</pre>
<pre>begin</pre>
<pre> Result:= '';</pre>
<pre> if not FileExists( _FileName) then exit;</pre>
<pre>
AssignFile( F, _FileName);</pre>
<pre> try</pre>
<pre> Reset( F, 1);</pre>
<pre> Longueur:= FileSize( F);</pre>
<pre> if 0 = Longueur then exit;</pre>
<pre> SetLength( Result, Longueur);</pre>
<pre> BlockRead( F, Result[1], Longueur);</pre>
<pre> finally</pre>
<pre> CloseFile( F);</pre>
<pre> end;</pre>
<pre>end;</pre>
<pre>
procedure String_to_File( _FileName: String; _S: String);</pre>
<pre>var</pre>
<pre> F: File;</pre>
<pre>begin</pre>
<pre> if '' = _S then exit;</pre>
<pre>
AssignFile( F, _FileName);</pre>
<pre> try</pre>
<pre> ReWrite( F, 1);</pre>
<pre> BlockWrite( F, _S[1], Length( _S));</pre>
<pre> finally</pre>
<pre> CloseFile( F);</pre>
<pre> end;</pre>
<pre>end;</pre>
<p></p>
<pre>
</pre>
<p><br>
</p>
</body>
</html>