level 1
seadau
楼主
//本地消息接收 二进制格式文件传输
//using System.Runtime.Serialization.Formatters.Binary;
this.localMessageQueue = new MessageQueue(local_mq.Text);
byte[] bytes=new byte[1024*1024*4];
System.Messaging.Message Msg = new System.Messaging.Message(bytes, new BinaryMessageFormatter());
//使用BinaryMessageFormatter这个类型进行串行化,默认情况下,这个属性不进行赋值的话就是XmlMessageFormatter
Msg = localMessageQueue.Receive();
IFormatter bf = new BinaryFormatter();
object obj = bf.Deserialize(Msg.BodyStream);
bytes= (byte[])obj;
//bytes= (byte[])Msg.Body;
//byte[] bytes = Convert.FromBase64String(pic);//声明一个byte[]用来存放Base64解码转换过来的数据流
//byte[] bytes = (byte[])Msg.Body;
//声明一个byte[]用来存放数据流
//创建文件流并保存
FileStream outfile = new System.IO.FileStream("C://zhou_xingchi.mp3", System.IO.FileMode.CreateNew);
outfile.Write(bytes, 0, (int)bytes.Length);
localMessageQueue.Close();
2012年07月04日 08点07分
1
//using System.Runtime.Serialization.Formatters.Binary;
this.localMessageQueue = new MessageQueue(local_mq.Text);
byte[] bytes=new byte[1024*1024*4];
System.Messaging.Message Msg = new System.Messaging.Message(bytes, new BinaryMessageFormatter());
//使用BinaryMessageFormatter这个类型进行串行化,默认情况下,这个属性不进行赋值的话就是XmlMessageFormatter
Msg = localMessageQueue.Receive();
IFormatter bf = new BinaryFormatter();
object obj = bf.Deserialize(Msg.BodyStream);
bytes= (byte[])obj;
//bytes= (byte[])Msg.Body;
//byte[] bytes = Convert.FromBase64String(pic);//声明一个byte[]用来存放Base64解码转换过来的数据流
//byte[] bytes = (byte[])Msg.Body;
//声明一个byte[]用来存放数据流
//创建文件流并保存
FileStream outfile = new System.IO.FileStream("C://zhou_xingchi.mp3", System.IO.FileMode.CreateNew);
outfile.Write(bytes, 0, (int)bytes.Length);
localMessageQueue.Close();