简单的帮助类:

        private static byte[] StreamToBytes(Stream fs)
{
byte[] bArr = new byte[fs.Length];
fs.Read(bArr, , (int)fs.Length);
fs.Seek(, SeekOrigin.Begin);
return bArr;
} public static Stream BytesToStream(byte[] bytes)
{
Stream stream = new MemoryStream(bytes);
return stream;
} public static byte[] FileToBytes(string path)
{
using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read))
{
byte[] bArr = new byte[fileStream.Length];
fileStream.Read(bArr, , bArr.Length);
return bArr;
}
} public static string BytesToFile(string directoryPath,byte[] bArr,string fileName)
{
if (!Directory.Exists(directoryPath))
{
Directory.CreateDirectory(directoryPath);
}
string path = directoryPath + "\\" + fileName;
using (FileStream fileStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write))
{
fileStream.Seek(, SeekOrigin.Begin);
fileStream.Write(bArr, , bArr.Length);
}
return path;
}

最新文章

  1. 由乱序播放说开了去-数组的打乱算法Fisher–Yates Shuffle
  2. RSA不限长度非对称加密解密C#
  3. 如何设置unobtrusive的语言包
  4. Android 5.0 如何正确启用isLoggable(一)__使用详解
  5. Redis入门指南
  6. J2EE 第二阶段项目(八)
  7. [转载]java NIO详解
  8. GPT分区基础知识及如何在GPT分区上安装WIN7
  9. webpShere中数据库集群url的设置
  10. poj1222
  11. [js高手之路]深入浅出webpack教程系列6-插件使用之html-webpack-plugin配置(下)
  12. FCM算法的matlab程序2
  13. 轻量级浏览器Midori
  14. 一起来给iOS 11找bug: 苹果还是乔布斯时代的细节控吗?
  15. RedHat7安装vmware虚拟机启动报错
  16. C/C++-标准输入/输出重定向为文件输入/输出
  17. netcore如何引用package?
  18. 搞笑的<Button></Button>
  19. Sqli-labs less 7
  20. 第02章-装配Bean

热门文章

  1. 为何在查询中索引未被使用 (Doc ID 1549181.1)
  2. Opencv距离变换distanceTransform应用——细化字符轮廓&&查找物体质心
  3. Kinect 骨骼映射---Let me dance for U!
  4. [Node.js] Use nodejs-dashboard event loop delay with hrtime()
  5. 高性能 Python —— vectorization
  6. auto_create_partition
  7. [tmux] Organize your terminal using tmux panes
  8. 【a501】算24点
  9. Sitecore
  10. 【b604】2K进制数