FileStream fs = new FileStream("c:\\dd.bin ", FileMode.OpenOrCreate, FileAccess.ReadWrite);
BinaryWriter binw = new BinaryWriter(fs);
byte[] bytes = { 0x23, 0x22, 0x55 };
binw.Write(bytes); binw.Close();
fs.Close();
using (FileStream fsSource = new FileStream("c:\\dd.bin ",FileMode.Open, FileAccess.Read))
{
bytes = null;
// Read the source file into a byte array.
bytes = new byte[fsSource.Length];
int numBytesToRead = (int)fsSource.Length;
int numBytesRead = 0;
while (numBytesToRead > 0)
{
// Read may return anything from 0 to numBytesToRead.
int n = fsSource.Read(bytes, numBytesRead, numBytesToRead); // Break when the end of the file is reached.
if (n == 0)
break; numBytesRead += n;
numBytesToRead -= n;
}
numBytesToRead = bytes.Length;
}
上面的代码存储的是byte[] bytes类型数组编程流文件,我想是否能很方便的存储short[]类型数组,并且很方便读取成short[]类型数组?
请教怎么写
解决方案 »
- vs2008+sql的结账代码
- DataGridViewComboBoxColumn的使用问题
- winform如何实现像网页中gridview那样的模板列功能?
- 寻找高手帮助解决
- Ajax技术的个人日历系统(那我前辈懂点的给我点建议,谢谢了)
- 杭州的C# winform开发高手请进?合作开发项目,有钱赚!!!!!!!!
- 关于C#的登录界面
- 在C#中,如何将图片存入数据库?
- win forms中关于DataGrid的问题
- 给一个c#连接sybase数据库的例子,谢谢!
- -----WPF DataGrid新手问题--------------------------@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- 关于DataRow的问题!
请教怎么写