问题
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("[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 but I want to put myicon.ico
for shortcuts icon .
how can I do this ?
回答1:
You can use the following steps:
- Right click on your project in the Solution Explorer and select Properties.
- Application tab
- Icon and manifest
- Select icon
来源:https://stackoverflow.com/questions/31472297/how-to-add-icon-to-applications-shortcut-in-desktop