Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get application icon of C# WinForms App

Tags:

c#

winforms

icons

I've assigned an icon to a C# WinForms app using the Project Properties tab. This icon is supplied along with the program manifest at build time. Is there a way to get an System.Drawing.Icon object of this icon at runtime, without having to embed it in resources again?

I've done my research; There's a way to extract an icon out of an EXE, but nothing I can find to extract the icon off the running C# application from within the application.

like image 401
Robin Rodricks Avatar asked Aug 20 '14 11:08

Robin Rodricks


People also ask

How do I get an app icon?

Right-click the EXE file for the software you want to extract an icon from and select Properties. Click the Icons tab shown directly below. Select an icon to extract there.

How do I specify an Application icon Visual Basic C?

On the menu bar, choose Project > Properties. When the Project Designer appears, choose the Application tab. (Visual Basic)—In the Icon list, choose an icon (. ico) file.

How do I change the icon of an EXE file?

Select the current icon and click Modify selected icon.... Another file browser window will expand. Select your ICO file and click Open. In the File Explorer window, go to the location of your icon file, then click the icon file to select it. You'll now see the replacement icon.

How do I change the default exe icon in C# Windows Application?

With a project selected in Solution Explorer, on the Project menu, click Properties. Select the Application pane. Select Browse from the Icon drop-down list and browse to the location of the icon file that you want.


1 Answers

Did you see the second answer in the link? (How can I get the icon from the executable file only having an instance of it's Process in C#)

//Gets the icon associated with the currently executing assembly
//(or pass a different file path and name for a different executable)
Icon appIcon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location);

That seems like it's getting the icon for the executing assembly.

like image 169
Wyatt Earp Avatar answered Sep 21 '22 17:09

Wyatt Earp