看到teamleader的博客里关于如何“在ClickOnce应用程序中创建桌面快捷方式 ”,本文对他的方式进行更简单的实现,为了文章完整,将他的文章拷贝过来了,见谅。如下是他文章的全文: ----------------------------------------------------------------------------------------------------------------- 在ClickOnce的发布选项中没有在桌面创建快捷方式的选项,而许多客户习惯于使用桌面快捷方式。 -------------------------------------------------------------------------------------------------------------------- 通过自己写入文件太麻烦,最简单方式:在程序启动时,进行拷贝 下面的是我的实现代码:
private static void CreateDesktopShortCut()
{ string path = System.Environment.GetFolderPath(Environment.SpecialFolder.StartMenu); if (!path.EndsWith("\\")) { path += "\\"; } path += @"Programs\杭州派尔科技有限公司"; if (System.IO.Directory.Exists(path)) { string desktop = System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); if (!desktop.EndsWith("\\")) { desktop += "\\"; } foreach (String file in System.IO.Directory.GetFiles(path)) { System.IO.FileInfo fi = new System.IO.FileInfo(file); if (!System.IO.File.Exists(desktop + fi.Name)) { fi.CopyTo(desktop + fi.Name); } } } }
|
|