Write binary data as a file

H. S. Teoh hsteoh at qfbox.info
Tue Aug 2 15:28:41 UTC 2022


On Tue, Aug 02, 2022 at 11:10:27AM +0000, Alexander Zhirov via Digitalmars-d-learn wrote:
[...]
> ```d
> auto result = db.query("select tcxs.settings_file as dbfile from
> amts.t_client_xrdp_settings tcxs where tcxs.pid_client = ?", id);
> ubyte[] bytes = cast(ubyte[])result.front()["dbfile"];
> write("newFile", bytes);
> ```

Don't use `write` for binary data. Use instead File.rawWrite:

	ubyte[] data = ...;
	File f = File("dbfile", "w");
	f.rawWrite(data[]);


T

-- 
This is a tpyo.


More information about the Digitalmars-d-learn mailing list