public void DeleteForTarget() { var executablePathFile = Assembly.GetExecutingAssembly().Location; var executablePath = Path.GetDirectoryName(executablePathFile); const string Shortcutname = "A6B1E7DE-8693-4354-9DA0-8181F072C20F"; var shortcutPathFile = Path.Combine(executablePath, Shortcutname) + "." + CompulsoryCat.Shell.Shortcut.Suffix; // Delete any already existing shortcuts. CompulsoryCat.Shell.Shortcut.DeleteForTarget(executablePath, executablePathFile); Assert.IsFalse(Exists(shortcutPathFile)); // Create a shortcut. using (var shortcut = new CompulsoryCat.Shell.Shortcut()) { shortcut.Target = executablePathFile; shortcut.WorkingDirectory = executablePath; shortcut.Description = string.Format("Link to {0}", Shortcutname); shortcut.DisplayMode = CompulsoryCat.Shell.Shortcut.LinkDisplayMode.edmNormal; shortcut.Save(shortcutPathFile); } Assert.IsTrue(Exists(shortcutPathFile)); // Delete the shortcut. CompulsoryCat.Shell.Shortcut.DeleteForTarget(Path.GetDirectoryName(shortcutPathFile), executablePathFile); Assert.IsFalse(Exists(shortcutPathFile)); }
public void Save() { var executablePathFile = Assembly.GetExecutingAssembly().Location; var executablePath = Path.GetDirectoryName(executablePathFile); const string Shortcutname = "0BDA2F85-D2ED-4E2D-B3DE-44B08950DE76"; var shortcutPathFile = Path.Combine(executablePath, Shortcutname) + "." + CompulsoryCat.Shell.Shortcut.Suffix; // Delete any already existing shortcuts. CompulsoryCat.Shell.Shortcut.DeleteForTarget(executablePath, executablePathFile); Assert.IsFalse(Exists(shortcutPathFile)); // Create a shortcut. using (var shortcut = new CompulsoryCat.Shell.Shortcut()) { shortcut.Target = executablePathFile; shortcut.WorkingDirectory = executablePath; shortcut.Description = string.Format("Link to {0}", Shortcutname); shortcut.DisplayMode = CompulsoryCat.Shell.Shortcut.LinkDisplayMode.edmNormal; shortcut.Save(shortcutPathFile); } Assert.IsTrue(Exists(shortcutPathFile)); }