<Data>424dffffff8effffffd60100000000003600</Data>
???
这一段,应该是base64编码

byte[] byteimg = System.Convert.FromBase64String( datastring );
获取字节流

解决方案 »

  1.   

    按你上面的写会出现下面的错误啊
    Base-64 字符数组的无效长度。
      

  2.   

    已测试可以通过FromBase64String获得byte数组
    string str = "424dffffff8effffffd60100000000003600";
    byte[] b = System.Convert.FromBase64String( str );
    watch:
    - b {Length=0x1b} byte[]
    [0x0] 0xe3 byte
    [0x1] 0x6e byte
    [0x2] 0x1d byte
    [0x3] 0x7d byte
    [0x4] 0xf7 byte
    [0x5] 0xdf byte
    [0x6] 0x7d byte
    [0x7] 0xff byte
    [0x8] 0x1e byte
    [0x9] 0x7d byte
    [0xa] 0xf7 byte
    [0xb] 0xdf byte
    [0xc] 0x7d byte
    [0xd] 0xf7 byte
    [0xe] 0x7a byte
    [0xf] 0xd3 byte
    [0x10] 0x5d byte
    [0x11] 0x34 byte
    [0x12] 0xd3 byte
    [0x13] 0x4d byte
    [0x14] 0x34 byte
    [0x15] 0xd3 byte
    [0x16] 0x4d byte
    [0x17] 0x34 byte
    [0x18] 0xdf byte
    [0x19] 0xad byte
    [0x1a] 0x34 byte贴出你的代码看看
      

  3.   

    如果它不是通过base64编码的,这段代码不行,需要了解具体的数据的编码方式,xml内一般只能放置字符串,二进制数据需要编码。
      

  4.   

    首先谢谢你的帮忙!这部份的代码如下:
    ImgAuthor = xReader.GetAttribute(0);
                            //ImgAuthor=ImgAuthor.Replace("\r","");
                            //ImgAuthor = ImgAuthor.Replace("\n", "");
                            //ImgAuthor = ImgAuthor.Replace("\"", "\\" + "\"");
                            ImgAuthor=DbHelperSQL.InputText(ImgAuthor, 25);
                            Re = xReader.GetAttribute(1);
                            xReader.Read();
                            if (xReader.Name == "Data")
                            {
                                xReader.Read();
                                if (xReader.Value != "Unknown")
                                {
                                    Docmodel = new PrjPaper.Model.TabDocuments();
                                    Docmodel.Title = Re;
                                    Docmodel.DocName = "Img";
                                    Docmodel.DocType = "image/bmp";     //"image/pjpeg";
                                    //string str = xReader.ReadContentAs(typeof(byte[]), null);
                                    string str=xReader.ReadContentAsString();
                                    //Docmodel.Contents=xReader.ReadContentAsBase64(typeof(byte[]),0,
                                    Docmodel.Contents = System.Convert.FromBase64String(str);
                                    //Docmodel.Contents = (byte[])xReader.ReadContentAs(typeof(byte[]), null);
                                    //Docmodel.Contents = DbHelperSQL.StringToByte(xReader.ReadContentAs(typeof(string), null));
                                    Docmodel.Author = ImgAuthor;
                                    Docmodel.Redate = System.Convert.ToDateTime(SpaceDate);
                                    DocID = Docbll.Add(Docmodel);                                imgmodel.NewsID = newsmodel.ID;
                                    imgmodel.ImgDocID = DocID;
                                    imgbll.Add(imgmodel);
                                }
                            }
      

  5.   

    Data部份太大,我都贴不出来!我有问了写xml文件的程序员,他说是按16进制写的