2013-03-27 80 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」 的身份。現在它可以工作。似乎它是某種「許可」問題。