2013-03-27 83 views
0

我想用下面的代码将图标转换为Web服务器上的PNG。但是在保存位图时,我总是得到“GDI +通用错误”。我错过了什么?将图标转换为Web服务器C上的PNG文件#

private static byte[] IconAsSizedPng(byte[] iconBytes, int iSize) 
    { 
     System.Drawing.Icon icon; 
     using(var ms = new System.IO.MemoryStream(iconBytes)) 
      icon = new System.Drawing.Icon(ms, iSize, iSize); 
     using(icon) { 
      using(var bmp = icon.ToBitmap()) { 
       //bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Png); 
       using(var ms = new System.IO.MemoryStream()) { 
        bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png); 
        return ms.ToArray(); 
       } 
      } 
     } 
    } 

字节的数据是:

System.IO.File.ReadAllBytes(filePath) 

回答

0

我不得不改变AppPoolUser以 “LocalSystems” 的身份。现在它可以工作。似乎它是某种“许可”问题。