1.用BinaryWriter写string 的时候会在文件开头多出一个字符数。
2.若要从二进制流中写二进制,务必别转换成string写byte,这样会产生一些符号出错。
3.网络二进制流读与写代码:
void Callback(IAsyncResult asyncResult)
{
FileInfo f = new FileInfo(@"D:\test2.mf");
using (BinaryWriter bWriter = new BinaryWriter(f.OpenWrite()))
{
WebRequest request = asyncResult.AsyncState as WebRequest;
WebResponse response = request.EndGetResponse(asyncResult);
Stream responseStream = response.GetResponseStream();
BinaryReader bReader = new BinaryReader(responseStream);
byte[] buffer = oReader.ReadBytes(10000000);
bw.Write(buffer);
}
}