Наследование: IDisposable
Пример #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 bool HasShortcut()
 {
     if (!File.Exists(ShortcutLocation))
     {
         return(false);
     }
     using (var shortcut = new ShellLink(ShortcutLocation)) {
         return(shortcut.AppUserModelID == AppUserModelId);
     }
 }
Пример #3
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);
            }
        }
Пример #4
0
 public static bool HasShortcut() {
     if (!File.Exists(ShortcutLocation)) return false;
     using (var shortcut = new ShellLink(ShortcutLocation)) {
         return shortcut.AppUserModelID == AppUserModelId;
     }
 }