Guardar matriz de bytes en archivo [duplicar]


Esta pregunta ya tiene una respuesta aquí:

Tengo una matriz de bytes (unerableumerable en realidad), y necesito guardarla en un nuevo archivo que contenga estos datos.

¿Cómo hago eso?

Encontré algunas respuestas que dicen cómo crear un MemoryStream a partir de eso, pero aún no puedo guardarlo a un archivo nuevo.

Author: Daniel Möller, 2013-10-18

2 answers

Puedes usar:

File.WriteAllBytes("Foo.txt", arrBytes); // Requires System.IO

Si tienes un array enumerable y no un array, puedes usar:

File.WriteAllBytes("Foo.txt", arrBytes.ToArray()); // Requires System.Linq
 196
Author: Mike Christensen,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-10-18 17:13:29

Puede usar el archivo .WriteAllBytes

 17
Author: Anirudha,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-10-18 17:13:40