将字节数组保存到文件 [英] Save byte array to file

查看:28
本文介绍了将字节数组保存到文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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.

解决方案

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

这篇关于将字节数组保存到文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆