ASP.NET MVC 动态加载图像

2020-12-13 01:44

阅读:691

标签:string   cti   c   type   name   .net   


        private ImageInfo CreateImageFile(string fileName)
        {
            if (!File.Exists(fileName))
                return null;
            Image image = Image.FromFile(fileName);
            MemoryStream ms = new MemoryStream();
            image.Save(ms, ImageFormat.Png);
            image.Dispose();
            ImageInfo result = new ImageInfo();
            result.contentType = "image/png";
            result.fileContents = ms.ToArray();
            return result;
        }

        public ActionResult DisplayImage(string fileName)
        {
            ImageInfo imageInfo = CreateImageFile(Server.MapPath(fileName));
            if (imageInfo == null)
                return imageInfo == null ? "" : File(imageInfo.fileContents, imageInfo.contentType);
        }

    

 

ASP.NET MVC 动态加载图像,搜素材,soscw.com

ASP.NET MVC 动态加载图像

标签:string   cti   c   type   name   .net   

原文地址:http://www.cnblogs.com/sungang3225/p/3710700.html


评论


亲,登录后才可以留言!