Which is best to Use for creating a file from byte[]?
.net, c#, file
Solution
If you have a `byte[]`, you might as well just use `WriteAllBytes` and let the wrapper method worry about the rest. The `Stream` approach is useful when you are (oddly enough) streaming the data, meaning: you might not know it all when you start writing. Since you do have the `byte[]`, just us it. However, in the general case, note that `byte[]`-based APIs may have more impact on memory than `Stream`-based APIs, especially for large content.
Problem
I want to create a file using byte[], which one is best. ``` byte[] content=File.ReadAllBytes(@"C:\ServiceLog.txt"); FileStream stream = new FileStream(@"C:\ServiceLog1.txt", FileMode.Create, FileAccess.ReadWrite); stream.Write(content, 0, content.Length); stream.Close(); ``` or ``` File.WriteAllBytes(@"C:\12.txt",content); ```