Ejemplo n.º 1
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Response.ContentType = "image/jpeg";

            int bufferSize = 100;

            byte[] outbyte = new byte[bufferSize];
            long   retVal;
            long   startIndex = 0;

            using (IDataReader reader = IMGroup.GetBinaryClientLogo(IMGroupID))
            {
                if (reader.Read())
                {
                    startIndex = 0;
                    retVal     = reader.GetBytes(0, startIndex, outbyte, 0, bufferSize);

                    if (retVal == 0)
                    {
                        Response.Redirect(GlobalResourceManager.Strings["IMGroupLogoUrl"], true);
                    }

                    Stream stream = Response.OutputStream;
                    while (retVal == bufferSize)
                    {
                        stream.Write(outbyte, 0, bufferSize);
                        startIndex += bufferSize;
                        retVal      = reader.GetBytes(0, startIndex, outbyte, 0, bufferSize);
                    }
                    stream.Write(outbyte, 0, System.Convert.ToInt32(retVal));
                }
                else
                {
                    Response.Redirect(GlobalResourceManager.Strings["IMGroupLogoUrl"], true);
                }
            }
        }