Save Icon File To Hard Drive

前端 未结 1 680
囚心锁ツ
囚心锁ツ 2020-12-15 10:19

I know that this must be incredibly easy - It\'s unbelievable how long I have searched for an answer to this question based on how simple it is in VB6. I simply want to extr

相关标签:
1条回答
  • 2020-12-15 10:58

    You will get better results if you save the icon without first converting to a bitmap. This is because an "Icon" can contain multiple sizes whereas a bitmap is a single size chosen during the conversion.

    The Icon class does not have a save to file method, but it does have a save to FileStream method, so you can save it like this:

            string s = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\IconData.ico";
            using (FileStream fs = new FileStream(s, FileMode.Create))
                ico.Save(fs);
    
    0 讨论(0)
提交回复
热议问题