Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# console application icon

Tags:

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

like image 513
pour toi Avatar asked Jul 23 '09 08:07

pour toi


2 Answers

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.

like image 132
IGadget Avatar answered Sep 17 '22 18:09

IGadget


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.

like image 24
Jon Skeet Avatar answered Sep 18 '22 18:09

Jon Skeet