C# console application icon

感情迁移 提交于 2019-12-17 07:42:55

问题


Does anyone know how to set a C# console application's icon in the code (not using project properties in Visual Studio)?


回答1:


You can't specify an executable's icon in code - it's part of the binary file itself.

From the command line you'd use /win32icon:<file> if that's any help, but you can't specify it within the code of the application. Don't forget that most of the time the application's icon is displayed, your app isn't running at all!

That's assuming you mean the icon for the file itself in explorer. If you mean the icon of the application while it's running if you just double-click the file, I believe that will always just be the icon for the console itself.




回答2:


You can change it in the project properties.

See this Stack Overflow article: Is it possible to change a console window's icon from .net?

To summarize right click on your project (not the solution) in Visual Studio and select properties. At the bottom of the "Application" tab there is a section for "Icon and manifest" where you can change the icon.



来源:https://stackoverflow.com/questions/1170383/c-sharp-console-application-icon

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!