public static ShellLink CreateShortcut(string shortcutPath, string actualFilePath, string description = null, string workingDirectory = null, string arguments = null) { shortcutPath = shortcutPath.GetFullPath(); actualFilePath = actualFilePath.GetFullPath(); if (!System.IO.Path.HasExtension(shortcutPath)) { shortcutPath += ".LNK"; } var link = new ShellLink(shortcutPath); link.Path = actualFilePath; link.WorkingDirectory = workingDirectory ?? System.IO.Path.GetDirectoryName(actualFilePath); if (description != null) { link.Description = description; } if (arguments != null) { link.Arguments = arguments; } link.Save(shortcutPath); return(link); }
/// <summary> /// Load a shortcut from a file. /// </summary> /// <param name="linkPath"> A path to the file. </param> public static ShellLink Load(string linkPath) { var result = new ShellLink(); ((IPersistFile)result.shellLink).Load(linkPath, (int)STGM_FLAGS.STGM_READ); result.ReadConsoleProperties(); return(result); }
/// <summary> /// This should be only called by a ShellLink constructor /// </summary> /// <param name = "owner"></param> internal ConsoleProperties(ShellLink owner) : this() { this.owner = owner; }
/// <summary> /// Load a shortcut from a file. /// </summary> /// <param name = "linkPath">A path to the file.</param> public static ShellLink Load(string linkPath) { var result = new ShellLink(); ((IPersistFile)result.shellLink).Load(linkPath, (int)STGM_FLAGS.STGM_READ); result.ReadConsoleProperties(); return result; }
public static ShellLink CreateShortcut(string shortcutPath, string actualFilePath, string description = null, string workingDirectory = null, string arguments = null) { shortcutPath = shortcutPath.GetFullPath(); actualFilePath = actualFilePath.GetFullPath(); if (!System.IO.Path.HasExtension(shortcutPath)) shortcutPath += ".LNK"; var link = new ShellLink(shortcutPath); link.Path = actualFilePath; link.WorkingDirectory = workingDirectory ?? System.IO.Path.GetDirectoryName(actualFilePath); if (description != null) link.Description = description; if (arguments != null) link.Arguments = arguments; link.Save(shortcutPath); return link; }
/// <summary> /// This should be only called by a ShellLink constructor /// </summary> /// <param name="owner"> </param> internal ConsoleProperties(ShellLink owner) : this() { this.owner = owner; }