图片与流互转

            FileStream stream = new FileStream(Server.MapPath("aa/Logo.jpg"), FileMode.Open, FileAccess.Read);
            byte[] blob = new byte[stream.Length];
            stream.Read(blob, 0, (int)stream.Length);
            stream.Close();

            string a = "";
            for (int i = 0; i < blob.Length; i++)
            {
                a = a + blob[i].ToString();
                Response.Write(a);
            }

            FileStream fs = new FileStream("c:\\b.jpeg", FileMode.OpenOrCreate, FileAccess.Write);
            BinaryWriter bw = new BinaryWriter(fs);
            bw.Write((byte[])blob);
            bw.Close();
            hahaimage.ImageUrl = "c:\\b.jpeg";

posted on 2008-06-26 16:05  Far  阅读(181)  评论(0编辑  收藏  举报

导航