예제 #1
0
        public static void CreateShortcut()
        {
            if (HasShortcut())
            {
                return;
            }

            try {
                var directory = Path.GetDirectoryName(ShortcutLocation) ?? "";
                if (!Directory.Exists(directory))
                {
                    Directory.CreateDirectory(directory);
                }

                using (var shortcut = new ShellLink()) {
                    shortcut.TargetPath     = System.Reflection.Assembly.GetEntryAssembly().Location;
                    shortcut.Arguments      = "";
                    shortcut.AppUserModelID = AppUserModelId;
                    shortcut.Save(ShortcutLocation);
                }

                CreateShortcutCommand.RaiseCanExecuteChanged();
                DeleteShortcutCommand.RaiseCanExecuteChanged();
            } catch (Exception e) {
                NonfatalError.NotifyBackground("Can’t create shortcut", e);
            }
        }
예제 #2
0
 public static void DeleteShortcut()
 {
     if (File.Exists(ShortcutLocation))
     {
         File.Delete(ShortcutLocation);
         CreateShortcutCommand.RaiseCanExecuteChanged();
         DeleteShortcutCommand.RaiseCanExecuteChanged();
     }
 }
예제 #3
0
        public static void DeleteShortcut()
        {
            if (AppUserModelId == null)
            {
                throw new Exception("AppUserModelId not set");
            }

            if (File.Exists(ShortcutLocation))
            {
                File.Delete(ShortcutLocation);
                CreateShortcutCommand.RaiseCanExecuteChanged();
                DeleteShortcutCommand.RaiseCanExecuteChanged();
            }
        }