soheil yo soheil yo - 10 months ago 65
C# Question

how to add icon to application's shortcut in desktop

I want when user runs my c# application , the application will create a desktop shortcut to run application. I use this code :

private void appShortcutToDesktop(string linkName)
string deskDir = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);

using (StreamWriter writer = new StreamWriter(deskDir + "\\" + linkName + ".url"))
string app = System.Reflection.Assembly.GetExecutingAssembly().Location;
writer.WriteLine("URL=file:///" + app);
string icon = app.Replace('\\', '/');
writer.WriteLine("IconFile=" + icon);

private void button1_Click(object sender, EventArgs e)

This code creates shortcut but I want to put
for shortcuts icon .
how can I do this ?

Answer Source

You can use the following steps:

  1. Right click on your project in the Solution Explorer and select Properties.
  2. Application tab
  3. Icon and manifest
  4. Select icon