C# ico转png


    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();
        }
    }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM