百邪!!!

解决方案 »

  1.   

    可以把文件转换为Byte[]保存到MSMQ,
    不过MSMQ有限制,不能超过4M。
      

  2.   

    private static FileStream fs;
    ......for (int i = 0; i < fs.Length / 8192; i++)

       byte[] fixbyte = new byte[8192];
       fs.Read(fixbyte, 0, 8192);
       SaveToMSMQ(fixbyte);
    }其中SaveToMSMQ
    System.Messaging.Message myMessage = new System.Messaging.Message(byte[]);
    MessageQueue SendQueue = new MessageQueue(Queue_Path);
    SendQueue .Send(myMessage);
    接收时
    if (MessageQueue.Exists(Queue_Path))
    {
    ReceiveQueue = new MessageQueue(Queue_Path);
    ReceiveQueue.Formatter = new XmlMessageFormatter(new Type[] {byte[]}); byte[] subreceiveBytes= (byte[])ReceiveQueue.Receive().Body;
    //检查目前文件的大小,如果不够
             Array.Copy(subreceiveBytes, 0, receiveBytes, insertpoint, subreceiveBytes.Length);
             insertpoint += subreceiveBytes.Length;
    //如果大小等于原文件大小
                    Array.Copy(subreceiveBytes, 0, receiveBytes, insertpoint, subreceiveBytes.Length-1);
                    fs = new FileStream("temp." + fileDet.FILETYPE, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
                    fs.Write(receiveBytes, 0, receiveBytes.Length);
    }