.NET 4.x Создать ярлык на рабочем столе - C#
Формулировка задачи:
Создаю ярлык с параметрами запуска, например "chrome.exe" --disk-cache-dir="R:\RamCache".
Как добавить параметры (аргументы) в конец строки с пробелом?
shortcut.TargetPath = Application.ExecutablePath.ToLower() + param;
public static class CustomShortcut
{
public static void Create(string name, string param, string icon, string desc, string hotkey)
{
var shell = new WshShell();
string shortcutPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
name + ".lnk");
var shortcut = (IWshShortcut) shell.CreateShortcut(shortcutPath);
shortcut.TargetPath = Application.ExecutablePath.ToLower() + param;
shortcut.IconLocation = icon;
if (desc == null) throw new ArgumentNullException("");
shortcut.Description = desc;
shortcut.Hotkey = hotkey;
shortcut.Save();
MessageBox.Show(shortcut.TargetPath);
}
}Решение задачи: «.NET 4.x Создать ярлык на рабочем столе»
textual
Листинг программы
shortcut.TargetPath = string.Format("{0} {1}", Application.ExecutablePath.ToLower(), param);