谁能帮我把C#代码翻译成VB.NET
vb.net吧
全部回复
仅看楼主
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
level 12
'本地消息接收 二进制格式文件传输
'using System.Runtime.Serialization.Formatters.Binary;
Me.localMessageQueue = New MessageQueue(local_mq.Text)
Dim bytes As Byte() = New Byte(1024 * 1024 * 4 - 1) {}
Dim Msg As New System.Messaging.Message(bytes, New BinaryMessageFormatter())
'使用BinaryMessageFormatter这个类型进行串行化,默认情况下,这个属性不进行赋值的话就是XmlMessageFormatter
Msg = localMessageQueue.Receive()
Dim bf As IFormatter = New BinaryFormatter()
Dim obj As Object = bf.Deserialize(Msg.BodyStream)
bytes = DirectCast(obj, Byte())
'bytes= (byte[])Msg.Body;
'byte[] bytes = Convert.FromBase64String(pic);//声明一个byte[]用来存放Base64解码转换过来的数据流
'byte[] bytes = (byte[])Msg.Body;
'声明一个byte[]用来存放数据流
'创建文件流并保存
Dim outfile As FileStream = New System.IO.FileStream("C://zhou_xingchi.mp3", System.IO.FileMode.CreateNew)
outfile.Write(bytes, 0, CInt(bytes.Length))
localMessageQueue.Close()
机器译
2012年07月05日 09点07分 2
1