c# - how to add icon to application's shortcut in desktop -


i want when user runs c# application , application create desktop shortcut run application. use 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("[internetshortcut]");         writer.writeline("url=file:///" + app);         writer.writeline("iconindex=0");         string icon = app.replace('\\', '/');         writer.writeline("iconfile=" + icon);         writer.flush();     } }  private void button1_click(object sender, eventargs e) {     appshortcuttodesktop("myname"); } 

this code creates shortcut want put myicon.ico shortcuts icon . how can ?

you can use following steps:

  1. right click on project in solution explorer , select properties.
  2. application tab
  3. icon , manifest
  4. select icon

Comments