当前位置:编程学习 > C#/ASP.NET >>

通过FLASH 拍照 在.net 中获取并保存为图片 base64解密到二进制是错误

FLASH 点击保存 POST 到 IMAGE.ASPX页面

此为该页面代码
        Encoding myEncoding = Encoding.GetEncoding("utf-8");
        Stream resStream = Request.InputStream;
        byte[] filecontent = new byte[resStream.Length];
        resStream.Read(filecontent, 0, filecontent.Length);
        //数组转换为string以便转换base64使用
        string a = myEncoding.GetString(filecontent);
        //将string读取base64解密到byte数组

//--------------------------执行到这里时报错----------------------
        byte[] filecontent2 = Convert.FromBase64String(a);    


//--------------------------------------------------------------

//下面的代码也还没有完全测试通过。  在不执行64解密时候通过一下代码克生成有大小的文件。在上面的代码中byte[] 是有值的。
        FileStream filestream = new FileStream("D:/Web/camera/Img/b.bmp", FileMode.Create, FileAccess.Write);
        int sizeCount = resStream.Read(filecontent2, 0, filecontent2.Length);
        try
        {
            while (sizeCount > 0)
            {
                filestream.Write(filecontent2, 0, sizeCount);
                sizeCount = resStream.Read(filecontent2, 0, filecontent2.Length);
            }
        }
        catch (Exception ex)
        { }
        filestream.Close();
        resStream.Close();


FLASH程序是用的这种。
--------------------编程问答-------------------- 希望各位大虾帮忙看看,谢谢各位。 --------------------编程问答-------------------- --------------------编程问答-------------------- 有了解这方面的吗? --------------------编程问答-------------------- string a = myEncoding.GetString(filecontent);
//将string读取base64解密到byte数组

//--------------------------执行到这里时报错----------------------
byte[] filecontent2 = Convert.FromBase64String(a);    


当然会出错, 字符串a又不是base64格式的。

--------------------编程问答-------------------- 已OK了

谢谢各位
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,