BrightnessTray.Autostart.CheckStartupFolderShortcutsExists C# (CSharp) Метод

CheckStartupFolderShortcutsExists() публичный статический Метод

public static CheckStartupFolderShortcutsExists ( ) : bool
Результат bool
        public static bool CheckStartupFolderShortcutsExists()
        {
            string searchFile = Application.ExecutablePath;
            string startUpFolderPath =
              Environment.GetFolderPath(Environment.SpecialFolder.Startup);

            DirectoryInfo di = new DirectoryInfo(startUpFolderPath);
            FileInfo[] files = di.GetFiles("*.lnk");

            foreach (FileInfo fi in files)
            {
                string shortcutTargetFile = GetShortcutTargetFile(fi.FullName);

                if (shortcutTargetFile.Equals(searchFile,
                      StringComparison.InvariantCultureIgnoreCase))
                {
                    return true;
                }
            }

            return false;
        }

Usage Example

 private void AutostartMenuEventHandler(object sender, EventArgs e)
 {
     if (mnuAutostart.Checked)
     {
         // remove autostart entry
         Autostart.DeleteStartupFolderShortcut();
     }
     else
     {
         // create autostart entry
         Autostart.CreateStartupFolderShortcut();
     }
     mnuAutostart.Checked = Autostart.CheckStartupFolderShortcutsExists();
 }
All Usage Examples Of BrightnessTray.Autostart::CheckStartupFolderShortcutsExists