Take the 2-minute tour ×

This question already has an answer here:

I have a byte array (an IEnumerable actually), and I need to save it to a new file containing this data.

How do I do that?

I found some answers telling how to create a MemoryStream from that, but still can't save it to a brand new file.

share|improve this question
add comment

marked as duplicate by Robert Harvey Oct 18 '13 at 17:16


2 Answers

up vote 14 down vote accepted

You can use:

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

If you have an enumerable and not an array, you can use:

File.WriteAllBytes("Foo.txt", arrBytes.ToArray()); // Requires System.Linq
share|improve this answer
add comment

You can use File.WriteAllBytes

share|improve this answer
add comment
