码迷,mamicode.com
首页 > Windows程序 > 详细

C# ico转png

时间:2019-04-10 15:11:07      阅读:252      评论:0      收藏:0      [点我收藏+]

标签:详情   路径   ram   bsp   name   star   div   bin   tostring   

    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("ICO文件转PNG");
            string path = null;
            bool got = false;
            while (!got)
            {
                Console.WriteLine("请输入需要转换的文件完整路径,然后按下回车。");
                path = Console.ReadLine();
                if (!File.Exists(path))
                    Console.WriteLine("找不到文件,请确认路径是否正确。");
                else
                    got = true;
            }

            try
            {
                string save = Path.Combine(Path.GetDirectoryName(path), DateTime.Now.ToFileTime().ToString() + ".png");
                new Icon(path).ToBitmap().Save(save, ImageFormat.Png);//这里还可以转换成其他类型图片,详情ImageFormat
                Console.WriteLine("转换成功。");
                Process.Start(Path.GetDirectoryName(save));
            }
            catch { }
            Console.ReadKey();
        }
    }

 

C# ico转png

标签:详情   路径   ram   bsp   name   star   div   bin   tostring   

原文地址:https://www.cnblogs.com/RedSky/p/10683470.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!