windowsApplicationShortcut

windowsApplicationShortcut

本文介绍了在桌面WPF C#上创建快捷方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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#上创建快捷方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-12 12:14