日期:2014-05-17  浏览次数:21166 次

System.Runtime.InteropServices.ExternalException: GDI+ 中发生一般性错误。
net端接收flash上传的图像的二进制流,然后保存图片到服务器路径。现在纳闷死了老是报GDI+错误,关键是偶尔会报错,网上 也没查到合适的原因,麻烦擅长GDI这块的大侠帮忙看下是怎么回事。        

        Stream _stream = Request.InputStream;
        string path = HttpContext.Current.Request.MapPath("upload/");
        if (!Directory.Exists(path))
        {
            Directory.CreateDirectory(path);
        }
        try
        {
            using (Bitmap bitMap = new Bitmap(_stream))
            {
                string imgName = path + DateTime.Now.Ticks.ToString() + ".png";
                bitMap.Save(imgName, ImageFormat.Png);
            }
        }
        catch (Exception ex)
        {
            System.Web.HttpContext.Current.Response.Write(ex.Message);
        }

------解决方案--------------------
偶尔报错.......


catch捕获到的信息贴一下 啊;