-- 这是通过浏览某图片,把他存放到数据库中 string filename = txt_filename.Text; string filecomment = txt_filecomment.Text; string SlaveFileName = FileUpload1.PostedFile.FileName; byte[] FileContent_img = null; DateTime UploadTime = DateTime.Now.Date; string id = lbl_id.Text; RemoteRule remoteRule = (RemoteRule)GetRemoteingObjectByType(typeof(RemoteRule), "remoterule"); DataSet ds = new DataSet(); if (id == "") -- 显示图片的 byte[] Image_img = (byte[])ds_image.Tables[0].Rows[0]["Image_im"]; if (Image_img.Length == 0) return; int filelength = Image_img.Length; string imageName = ds_image.Tables[0].Rows[0][1].ToString() + "1" + ".jpg"; string myUrl = HttpContext.Current.Server.MapPath(this.Request.ApplicationPath) + @"\TempDownLoad\" + imageName; FileStream fs = new FileStream(myUrl, FileMode.OpenOrCreate); BinaryWriter w = new BinaryWriter(fs); w.BaseStream.Write(Image_img, 0, filelength); w.Flush(); w.Close(); Image1.ImageUrl = Context.Request.ApplicationPath + "/TempDownLoad/" + imageName; Bitmap bitmap = new Bitmap(myUrl); Image1.Width = bitmap.Width; Image1.Height = bitmap.Height; 相关文章: