文件&字节流转换
1、读取文件,转换为字节流
FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
byte[] bytesRead = new byte[(int)fs.Length];
fs.Read(bytesRead, 0, bytesRead.Length);
fs.Close();
return bytesRead;
2、将字节流写入文件
byte[] bytesWrite = ….
FileStream fs = new FileStream(“xxx”,FileMode.Create, FileAccess.Write);
fs.Write(bytesWrite, 0, bytesWrite.Length);
fs.Close();