After upgrading the code from .NET core3.1 to .NET6, and after starting using the VS2022 from VS2019, I am not able to see the default WinForms icon for my windows application.
Does anyone know how to solve this?
I tried looking for the icon properties for the project but could not find the default icon option in VS2022, which I can see in VS2019.
CodePudding user response:
First you can search for properties:
Select the icon
in the categorized:
The second method:
project
->properties
->Applications
->win32 resources
Update:
You could use this to get it.
using System;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Icon icon = this.Icon;
Stream output = new FileStream("saved_icon.ico", FileMode.Create);
icon.Save(output);
output.Close();
}
}
}