我希望当用户运行我的 C# 应用程序时,该应用程序将创建一个桌面快捷方式来运行应用程序。我使用这个代码:
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");
}
这段代码创建了快捷方式,但我想把myicon.ico
为快捷方式图标。
我怎样才能做到这一点 ?
您可以使用以下步骤:
- 右键单击您的项目解决方案浏览器并选择特性.
- 应用选项卡
- 图标和清单
- Select icon
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)