Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the most efficient way to save a byte array as a file on disk in C#?

Tags:

c#

.net

Pretty simple scenario. I have a web service that receives a byte array that is to be saved as a particular file type on disk. What is the most efficient way to do this in C#?

like image 274
Kilhoffer Avatar asked Sep 24 '08 17:09

Kilhoffer


People also ask

How do I save a byte file?

Java – How to save byte[] to a filewrite is the simplest solution to save byte[] to a file. // bytes = byte[] Path path = Paths. get("/path/file"); Files. write(path, bytes);

Which function is used to write an array of bytes into a file?

Convert byte[] array to File using Java In order to convert a byte array to a file, we will be using a method named the getBytes() method of String class.


2 Answers

That would be File.WriteAllBytes().

like image 85
Maurice Avatar answered Oct 02 '22 11:10

Maurice


System.IO.File.WriteAllBytes(path, data) should do fine.

like image 25
Khoth Avatar answered Oct 02 '22 13:10

Khoth