Save byte array to file

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

How to do it?

I found several answers telling how to create a MemoryStream, but cannot save it in a completely new file.

+56
c # file stream byte save
Oct 18 '13 at 17:11
source share
2 answers

You can use:

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

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

 File.WriteAllBytes("Foo.txt", arrBytes.ToArray()); // Requires System.Linq 
+156
Oct 18 '13 at 17:13
source share

You can use File.WriteAllBytes

+12
Oct 18 '13 at 17:13
source share



All Articles