问题描述
Error:
'System.Windows.Application' does not contain a definition for 'StartupPath'
'System.Windows.Application' does not contain a definition for 'ExecutablePath'
我尝试过:
使用IWshRuntimeLibrary;
var startupFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
var shell = new WshShell();
var shortCutLinkFilePath = System.IO.Path.Combine(startupFolderPath,@\ CreateShortcutSample.lnk);
var windowsApplicationShortcut =(IWshShortcut)shell.CreateS hortcut(shortCutLinkFilePath);
windowsApplicationShortcut.Description =如何为应用程序示例创建简短;
windowsApplicationShortcut.WorkingDirectory = Application.StartupPath;
windowsApplicationShortcut.TargetPath = Application.ExecutablePath;
windowsApplicationShortcut.Save();
What I have tried:
using IWshRuntimeLibrary;
var startupFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
var shell = new WshShell();
var shortCutLinkFilePath = System.IO.Path.Combine(startupFolderPath, @"\CreateShortcutSample.lnk");
var windowsApplicationShortcut = (IWshShortcut)shell.CreateShortcut(shortCutLinkFilePath);
windowsApplicationShortcut.Description = "How to create short for application example";
windowsApplicationShortcut.WorkingDirectory = Application.StartupPath;
windowsApplicationShortcut.TargetPath = Application.ExecutablePath;
windowsApplicationShortcut.Save();
推荐答案
这篇关于在桌面WPF C#上创建快捷方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!