File .WriteAllBytes or FileStream.Write

What is the difference between File.WriteAllBytes and FileStream.Write / WriteBytes? I have a bitmap object and I want to create a new bmp / ​​jpg / png on disk. I think I read somewhere that WriteAllBytes uses FileStream.Write under?

+5
source share
4 answers

WriteAllBytes- It’s just a convenience method that wraps up basic operations Stream. (Create a file, write to the stream, close the stream, etc.). Use it if it suits your needs. If you need more control over basic operations, return to using Streamor similar.

It's all about using the right abstraction for the task.

+15

WriteAllBytes, , Write, .

+3

. Image.Save(). , , , ( ). , , , Save(), ImageFormat. BMP Windows, . PNG , . JPEG , . .

+2

You must use WriteAllBytes if you want to save a bitmap.

+2
source

All Articles