Beispiel #1
0
        /// <summary>
        ///     Sets array of containing program file names which should be displayed in the Open With List.
        /// </summary>
        /// <param name="file"><see cref="FileAssociationInfo" /> that provides specifics of the extension to be changed.</param>
        /// <param name="programList">Program file names</param>
        protected void SetOpenWithList(FileAssociationInfo file, string[] programList)
        {
            if (!file.Exists)
            {
                throw new Exception("Extension does not exist");
            }

            var root = Registry.ClassesRoot;

            var key = root.OpenSubKey(file._extension, true);

            if (key != null)
            {
                var tmpkey = key.OpenSubKey("OpenWithList", true);
                if (tmpkey != null)
                {
                    key.DeleteSubKeyTree("OpenWithList");
                }

                key = key.CreateSubKey("OpenWithList");
                foreach (var s in programList)
                {
                    if (key != null)
                    {
                        key.CreateSubKey(s);
                    }
                }
            }

            ShellNotification.NotifyOfChange();
        }
Beispiel #2
0
        /// <summary>
        ///     Creates actual extension association key in registry for the specified extension and supplied attributes.
        /// </summary>
        /// <param name="progId">Name of expected handling program.</param>
        /// <param name="perceivedType"><see cref="PerceivedTypes" />PerceivedType of file type.</param>
        /// <param name="contentType">MIME type of file type.</param>
        /// <param name="openwithList"></param>
        /// <returns>FileAssociationInfo instance referring to specified extension.</returns>
        public FileAssociationInfo Create(string progId, PerceivedTypes perceivedType, string contentType,
                                          string[] openwithList)
        {
            var fai = new FileAssociationInfo(_extension);

            if (fai.Exists)
            {
                fai.Delete();
            }

            fai.Create();
            fai.ProgId = progId;

            if (perceivedType != PerceivedTypes.None)
            {
                fai.PerceivedType = perceivedType;
            }

            if (contentType != string.Empty)
            {
                fai.ContentType = contentType;
            }

            if (openwithList != null)
            {
                fai.OpenWithList = openwithList;
            }

            return(fai);
        }
Beispiel #3
0
        /// <summary>
        ///     Gets or value that determines the <see cref="PerceivedType" />PerceivedType of the file.
        /// </summary>
        /// <param name="file"><see cref="FileAssociationInfo" /> that provides specifics of the extension to be changed.</param>
        /// <returns><see cref="PerceivedTypes" /> that specifies Perceived Type of extension.</returns>
        protected PerceivedTypes GetPerceivedType(FileAssociationInfo file)
        {
            if (!file.Exists)
            {
                throw new Exception("Extension does not exist");
            }

            var val        = _registryWrapper.Read(file._extension, "PerceivedType");
            var actualType = PerceivedTypes.None;

            if (val == null)
            {
                return(actualType);
            }

            try
            {
                actualType = (PerceivedTypes)Enum.Parse(typeof(PerceivedTypes), val.ToString(), true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }


            return(actualType);
        }
Beispiel #4
0
        /// <summary>
        ///     Deletes actual file extension entry in registry.
        /// </summary>
        /// <param name="file"><see cref="FileAssociationInfo" /> instance that contains specifics on extension to be deleted.</param>
        protected void Delete(FileAssociationInfo file)
        {
            if (!file.Exists)
            {
                throw new Exception("Key not found.");
            }

            var root = Registry.ClassesRoot;

            root.DeleteSubKeyTree(file._extension);
        }
Beispiel #5
0
        /// <summary>
        ///     Sets a value that determines the <see cref="PerceivedType" />PerceivedType of the file.
        /// </summary>
        /// <param name="file"><see cref="FileAssociationInfo" /> that provides specifics of the extension to be changed.</param>
        /// <param name="type"><see cref="PerceivedTypes" /> to be set that specifies Perceived Type of extension.</param>
        protected void SetPerceivedType(FileAssociationInfo file, PerceivedTypes type)
        {
            if (!file.Exists)
            {
                throw new Exception("Extension does not exist");
            }

            _registryWrapper.Write(file._extension, "PerceivedType", type.ToString());

            ShellNotification.NotifyOfChange();
        }
Beispiel #6
0
        /// <summary>
        ///     Sets a value that determines the MIME type of the file.
        /// </summary>
        /// <param name="file"><see cref="FileAssociationInfo" /> that provides specifics of the extension to be changed.</param>
        /// <param name="type">MIME content type of extension.</param>
        protected void SetContentType(FileAssociationInfo file, string type)
        {
            if (!file.Exists)
            {
                throw new Exception("Extension does not exist");
            }

            _registryWrapper.Write(file._extension, "Content Type", type);

            ShellNotification.NotifyOfChange();
        }
Beispiel #7
0
        /// <summary>
        ///     Set a value that indicates the name of the associated application with the behavior to handle this extension.
        /// </summary>
        /// <param name="file"><see cref="FileAssociationInfo" /> that provides specifics of the extension to be changed.</param>
        /// <param name="progId">Associated Program ID of handling program.</param>
        protected void SetProgId(FileAssociationInfo file, string progId)
        {
            if (!file.Exists)
            {
                throw new Exception("Extension does not exist");
            }

            _registryWrapper.Write(file._extension, string.Empty, progId);

            ShellNotification.NotifyOfChange();
        }
Beispiel #8
0
        /// <summary>
        ///     Verifies that given extension exists and is associated with given program id
        /// </summary>
        /// <param name="extension">Extension to be checked for.</param>
        /// <param name="progId">progId to be checked for.</param>
        /// <returns>True if association exists, false if it does not.</returns>
        public bool IsValid(string extension, string progId)
        {
            var fai = new FileAssociationInfo(extension);

            if (!fai.Exists)
            {
                return(false);
            }

            return(progId == fai.ProgId);
        }
        /// <summary>
        ///     Associates an already existing program id with a list of extensions.
        /// </summary>
        /// <param name="progId">The program id to associate extensions with.</param>
        /// <param name="extensions">String array of extensions to associate with program id.</param>
        public void Associate(string progId, params string[] extensions)
        {
            foreach (var s in extensions)
            {
                var fai = new FileAssociationInfo(s);

                if (!fai.Exists)
                    fai.Create(progId);

                fai.ProgId = progId;
            }
        }
Beispiel #10
0
        /// <summary>
        ///     Associates an already existing program id with a list of extensions.
        /// </summary>
        /// <param name="progId">The program id to associate extensions with.</param>
        /// <param name="extensions">String array of extensions to associate with program id.</param>
        public void Associate(string progId, params string[] extensions)
        {
            foreach (var s in extensions)
            {
                var fai = new FileAssociationInfo(s);

                if (!fai.Exists)
                {
                    fai.Create(progId);
                }

                fai.ProgId = progId;
            }
        }
Beispiel #11
0
        /// <summary>
        ///     Gets a value that indicates the filter component that is used to search for text within documents of this type.
        /// </summary>
        /// <param name="file"><see cref="FileAssociationInfo" /> that provides specifics of the extension to be changed.</param>
        /// <returns>Guid of filter component.</returns>
        protected Guid GetPersistentHandler(FileAssociationInfo file)
        {
            if (!file.Exists)
            {
                throw new Exception("Extension does not exist");
            }

            var val = _registryWrapper.Read(file._extension + "\\PersistentHandler", string.Empty);

            if (val == null)
            {
                return(new Guid());
            }
            return(new Guid(val.ToString()));
        }
Beispiel #12
0
        /// <summary>
        ///     Gets a value that determines the MIME type of the file.
        /// </summary>
        /// <param name="file"><see cref="FileAssociationInfo" /> that provides specifics of the extension to be changed.</param>
        /// <returns>MIME content type of extension.</returns>
        protected string GetContentType(FileAssociationInfo file)
        {
            if (!file.Exists)
            {
                throw new Exception("Extension does not exist");
            }

            var val = _registryWrapper.Read(file._extension, "Content Type");

            if (val == null)
            {
                return(string.Empty);
            }
            return(val.ToString());
        }
Beispiel #13
0
        /// <summary>
        ///     Sets a value that indicates the filter component that is used to search for text within documents of this type.
        /// </summary>
        /// <param name="file"><see cref="FileAssociationInfo" /> that provides specifics of the extension to be changed.</param>
        /// <param name="persistentHandler">Guid of filter component.</param>
        protected void SetPersistentHandler(FileAssociationInfo file, Guid persistentHandler)
        {
            if (!file.Exists)
            {
                throw new Exception("Extension does not exist");
            }

            if (persistentHandler == Guid.Empty)
            {
                return;
            }

            _registryWrapper.Write(file._extension + "\\" + PersistentHandler, string.Empty, persistentHandler);

            ShellNotification.NotifyOfChange();
        }
Beispiel #14
0
        /// <summary>
        ///     Determines of the list of extensions are associated with the specified program id.
        /// </summary>
        /// <param name="progId">Program id to check against.</param>
        /// <param name="extensions">String array of extensions to check against the program id.</param>
        /// <returns>String array of extensions that were not associated with the program id.</returns>
        public string[] CheckAssociation(string progId, params string[] extensions)
        {
            var notAssociated = new List <string>();

            foreach (var s in extensions)
            {
                var fai = new FileAssociationInfo(s);

                if (!fai.Exists || fai.ProgId != progId)
                {
                    notAssociated.Add(s);
                }
            }

            return(notAssociated.ToArray());
        }
Beispiel #15
0
        /// <summary>
        ///     Creates actual file extension entry in registry.
        /// </summary>
        /// <param name="file"><see cref="FileAssociationInfo" /> instance that contains specifics on extension to be created.</param>
        protected void Create(FileAssociationInfo file)
        {
            if (file.Exists)
            {
                file.Delete();
            }

            var root = Registry.ClassesRoot;

            root.CreateSubKey(file._extension);
            var subKey = root.CreateSubKey("nUpdate Administration\\shell\\open\\command");

            if (subKey != null)
            {
                subKey.SetValue("", String.Format("{0} \"%1\" ", System.Windows.Forms.Application.ExecutablePath),
                                RegistryValueKind.String);
            }
        }
        /// <summary>
        ///     Associates a single executable with a list of extensions.
        /// </summary>
        /// <param name="progId">Name of program id</param>
        /// <param name="executablePath">Path to executable to start including arguments.</param>
        /// <param name="extensions">String array of extensions to associate with program id.</param>
        /// <example>
        ///     progId = "MyTextFile"
        ///     executablePath = "notepad.exe %1"
        ///     extensions = ".txt", ".text"
        /// </example>
        public void Associate(string progId, string executablePath, params string[] extensions)
        {
            foreach (var s in extensions)
            {
                var fai = new FileAssociationInfo(s);

                if (!fai.Exists)
                    fai.Create(progId);

                fai.ProgId = progId;
            }

            var pai = new ProgramAssociationInfo(progId);

            if (!pai.Exists)
                pai.Create();

            pai.AddVerb(new ProgramVerb("open", executablePath));
        }
Beispiel #17
0
        /// <summary>
        ///     Associates a single executable with a list of extensions.
        /// </summary>
        /// <param name="progId">Name of program id</param>
        /// <param name="executablePath">Path to executable to start including arguments.</param>
        /// <param name="extensions">String array of extensions to associate with program id.</param>
        /// <example>
        ///     progId = "MyTextFile"
        ///     executablePath = "notepad.exe %1"
        ///     extensions = ".txt", ".text"
        /// </example>
        public void Associate(string progId, string executablePath, params string[] extensions)
        {
            foreach (var s in extensions)
            {
                var fai = new FileAssociationInfo(s);

                if (!fai.Exists)
                {
                    fai.Create(progId);
                }

                fai.ProgId = progId;
            }

            var pai = new ProgramAssociationInfo(progId);

            if (!pai.Exists)
            {
                pai.Create();
            }

            pai.AddVerb(new ProgramVerb("open", executablePath));
        }
Beispiel #18
0
        /// <summary>
        ///     Gets array of containing program file names which should be displayed in the Open With List.
        /// </summary>
        /// <param name="file"><see cref="FileAssociationInfo" /> that provides specifics of the extension to be changed.</param>
        /// <returns>Program file names</returns>
        protected string[] GetOpenWithList(FileAssociationInfo file)
        {
            if (!file.Exists)
            {
                throw new Exception("Extension does not exist");
            }

            var root = Registry.ClassesRoot;
            var key  = root.OpenSubKey(file._extension);

            if (key != null)
            {
                key = key.OpenSubKey("OpenWithList");

                if (key == null)
                {
                    return(new string[0]);
                }

                return(key.GetSubKeyNames());
            }

            return(null);
        }
Beispiel #19
0
        /// <summary>
        ///     Creates actual extension association key in registry for the specified extension and supplied attributes.
        /// </summary>
        /// <param name="progId">Name of expected handling program.</param>
        /// <param name="perceivedType"><see cref="PerceivedTypes" />PerceivedType of file type.</param>
        /// <param name="contentType">MIME type of file type.</param>
        /// <param name="openwithList"></param>
        /// <returns>FileAssociationInfo instance referring to specified extension.</returns>
        public FileAssociationInfo Create(string progId, PerceivedTypes perceivedType, string contentType,
            string[] openwithList)
        {
            var fai = new FileAssociationInfo(_extension);

            if (fai.Exists)
                fai.Delete();

            fai.Create();
            fai.ProgId = progId;

            if (perceivedType != PerceivedTypes.None)
                fai.PerceivedType = perceivedType;

            if (contentType != string.Empty)
                fai.ContentType = contentType;

            if (openwithList != null)
                fai.OpenWithList = openwithList;

            return fai;
        }
Beispiel #20
0
        ///// <summary>
        /////     Sets the language
        ///// </summary>
        //public void SetLanguage()
        //{
        //    string languageFilePath = Path.Combine(Program.LanguagesDirectory,
        //        String.Format("{0}.json", Settings.Default.Language.Name));
        //    if (File.Exists(languageFilePath))
        //        _lp = Serializer.Deserialize<LocalizationProperties>(File.ReadAllText(languageFilePath));
        //    else
        //    {
        //        File.WriteAllBytes(Path.Combine(Program.LanguagesDirectory, "en.json"), Resources.en);
        //        Settings.Default.Language = new CultureInfo("en");
        //        Settings.Default.Save();
        //        Settings.Default.Reload();
        //        _lp = Serializer.Deserialize<LocalizationProperties>(File.ReadAllText(languageFilePath));
        //    }
        //    Text = _lp.ProductTitle;
        //    headerLabel.Text = _lp.ProductTitle;
        //    infoLabel.Text = _lp.MainDialogInfoText;
        //    sectionsListView.Groups[0].Header = _lp.MainDialogProjectsGroupText;
        //    sectionsListView.Groups[1].Header = _lp.MainDialogInformationGroupText;
        //    sectionsListView.Groups[2].Header = _lp.MainDialogPreferencesGroupText;
        //    sectionsListView.Items[0].Text = _lp.MainDialogNewProjectText;
        //    sectionsListView.Items[1].Text = _lp.MainDialogOpenProjectText;
        //    sectionsListView.Items[4].Text = _lp.MainDialogFeedbackText;
        //    sectionsListView.Items[5].Text = _lp.MainDialogPreferencesText;
        //    sectionsListView.Items[6].Text = _lp.MainDialogInformationText;
        //}
        private void MainDialog_Load(object sender, EventArgs e)
        {
            if (Environment.OSVersion.Version.Major < 6)
            {
                var dr = MessageBox.Show("Your operating system is not supported.", String.Empty,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                if (dr == DialogResult.OK)
                    Application.Exit();
            }

            try
            {
                var fai = new FileAssociationInfo(".nupdproj");
                if (!fai.Exists)
                {
                    fai.Create("nUpdate Administration");

                    var pai = new ProgramAssociationInfo(fai.ProgId);
                    if (!pai.Exists)
                    {
                        pai.Create("nUpdate Administration Project File",
                            new ProgramVerb("Open", String.Format("\"{0} %1\"", Application.ExecutablePath)));
                        pai.DefaultIcon = new ProgramIcon(Application.ExecutablePath);
                    }
                }
            }
            catch (UnauthorizedAccessException)
            {
                Popup.ShowPopup(this, SystemIcons.Warning, "Missing rights.", "The registry entry for the extension (.nupdproj) couldn't be created. Without that file extension nUpdate Administration won't work correctly. Please make sure to start the administration with admin privileges the first time.",
                    PopupButtons.Ok);
            }

            if (String.IsNullOrWhiteSpace(Settings.Default.ProgramPath))
                Settings.Default.ProgramPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                    "nUpdate Administration");
            Program.LanguagesDirectory = Path.Combine(Program.Path, "Localization");
            if (!Directory.Exists(Program.LanguagesDirectory))
            {
                Directory.CreateDirectory(Program.LanguagesDirectory); // Create the directory

                // Save the language content
                var lang = new LocalizationProperties();
                var content = Serializer.Serialize(lang);
                File.WriteAllText(Path.Combine(Program.LanguagesDirectory, "en.json"), content);
            }

            if (!File.Exists(Program.ProjectsConfigFilePath))
            {
                using (File.Create(Program.ProjectsConfigFilePath))
                {
                }
            }

            if (!File.Exists(Program.StatisticServersFilePath))
            {
                using (File.Create(Program.StatisticServersFilePath))
                {
                }
            }

            var projectsPath = Path.Combine(Program.Path, "Projects");
            if (!Directory.Exists(projectsPath))
                Directory.CreateDirectory(projectsPath);

            //SetLanguage();
            sectionsListView.DoubleBuffer();
            Text = String.Format(Text, Program.VersionString);
            headerLabel.Text = String.Format(Text, Program.VersionString);
        }
Beispiel #21
0
        /// <summary>
        ///     Verifies that given extension exists and is associated with given program id
        /// </summary>
        /// <param name="extension">Extension to be checked for.</param>
        /// <param name="progId">progId to be checked for.</param>
        /// <returns>True if association exists, false if it does not.</returns>
        public bool IsValid(string extension, string progId)
        {
            var fai = new FileAssociationInfo(extension);

            if (!fai.Exists)
                return false;

            return progId == fai.ProgId;
        }
Beispiel #22
0
        /// <summary>
        ///     Creates actual file extension entry in registry.
        /// </summary>
        /// <param name="file"><see cref="FileAssociationInfo" /> instance that contains specifics on extension to be created.</param>
        protected void Create(FileAssociationInfo file)
        {
            if (file.Exists)
                file.Delete();

            var root = Registry.ClassesRoot;
            root.CreateSubKey(file._extension);
            var subKey = root.CreateSubKey("nUpdate Administration\\shell\\open\\command");
            if (subKey != null)
                subKey.SetValue("", String.Format("{0} \"%1\" ", System.Windows.Forms.Application.ExecutablePath),
                    RegistryValueKind.String);
        }
Beispiel #23
0
        /// <summary>
        ///     Deletes actual file extension entry in registry.
        /// </summary>
        /// <param name="file"><see cref="FileAssociationInfo" /> instance that contains specifics on extension to be deleted.</param>
        protected void Delete(FileAssociationInfo file)
        {
            if (!file.Exists)
                throw new Exception("Key not found.");

            var root = Registry.ClassesRoot;
            root.DeleteSubKeyTree(file._extension);
        }
Beispiel #24
0
        /// <summary>
        ///     Gets array of containing program file names which should be displayed in the Open With List.
        /// </summary>
        /// <param name="file"><see cref="FileAssociationInfo" /> that provides specifics of the extension to be changed.</param>
        /// <returns>Program file names</returns>
        protected string[] GetOpenWithList(FileAssociationInfo file)
        {
            if (!file.Exists)
                throw new Exception("Extension does not exist");

            var root = Registry.ClassesRoot;
            var key = root.OpenSubKey(file._extension);

            if (key != null)
            {
                key = key.OpenSubKey("OpenWithList");

                if (key == null)
                    return new string[0];

                return key.GetSubKeyNames();
            }

            return null;
        }
Beispiel #25
0
        /// <summary>
        ///     Sets a value that indicates the filter component that is used to search for text within documents of this type.
        /// </summary>
        /// <param name="file"><see cref="FileAssociationInfo" /> that provides specifics of the extension to be changed.</param>
        /// <param name="persistentHandler">Guid of filter component.</param>
        protected void SetPersistentHandler(FileAssociationInfo file, Guid persistentHandler)
        {
            if (!file.Exists)
                throw new Exception("Extension does not exist");

            if (persistentHandler == Guid.Empty)
                return;

            _registryWrapper.Write(file._extension + "\\" + PersistentHandler, string.Empty, persistentHandler);

            ShellNotification.NotifyOfChange();
        }
Beispiel #26
0
        /// <summary>
        ///     Gets a value that indicates the filter component that is used to search for text within documents of this type.
        /// </summary>
        /// <param name="file"><see cref="FileAssociationInfo" /> that provides specifics of the extension to be changed.</param>
        /// <returns>Guid of filter component.</returns>
        protected Guid GetPersistentHandler(FileAssociationInfo file)
        {
            if (!file.Exists)
                throw new Exception("Extension does not exist");

            var val = _registryWrapper.Read(file._extension + "\\PersistentHandler", string.Empty);

            if (val == null)
                return new Guid();
            return new Guid(val.ToString());
        }
Beispiel #27
0
        /// <summary>
        ///     Gets a value that indicates the name of the associated application with the behavior to handle this extension.
        /// </summary>
        /// <param name="file"><see cref="FileAssociationInfo" /> that provides specifics of the extension to be changed.</param>
        /// <returns>Associated Program ID of handling program.</returns>
        protected string GetProgId(FileAssociationInfo file)
        {
            if (!file.Exists)
                throw new Exception("Extension does not exist");

            var val = _registryWrapper.Read(file._extension, string.Empty);

            if (val == null)
                return string.Empty;

            return val.ToString();
        }
Beispiel #28
0
        /// <summary>
        ///     Sets a value that determines the MIME type of the file.
        /// </summary>
        /// <param name="file"><see cref="FileAssociationInfo" /> that provides specifics of the extension to be changed.</param>
        /// <param name="type">MIME content type of extension.</param>
        protected void SetContentType(FileAssociationInfo file, string type)
        {
            if (!file.Exists)
                throw new Exception("Extension does not exist");

            _registryWrapper.Write(file._extension, "Content Type", type);

            ShellNotification.NotifyOfChange();
        }
Beispiel #29
0
        /// <summary>
        ///     Sets array of containing program file names which should be displayed in the Open With List.
        /// </summary>
        /// <param name="file"><see cref="FileAssociationInfo" /> that provides specifics of the extension to be changed.</param>
        /// <param name="programList">Program file names</param>
        protected void SetOpenWithList(FileAssociationInfo file, string[] programList)
        {
            if (!file.Exists)
                throw new Exception("Extension does not exist");

            var root = Registry.ClassesRoot;

            var key = root.OpenSubKey(file._extension, true);
            if (key != null)
            {
                var tmpkey = key.OpenSubKey("OpenWithList", true);
                if (tmpkey != null)
                    key.DeleteSubKeyTree("OpenWithList");

                key = key.CreateSubKey("OpenWithList");
                foreach (var s in programList)
                {
                    if (key != null)
                        key.CreateSubKey(s);
                }
            }

            ShellNotification.NotifyOfChange();
        }
Beispiel #30
0
        /// <summary>
        ///     Sets a value that determines the <see cref="PerceivedType" />PerceivedType of the file.
        /// </summary>
        /// <param name="file"><see cref="FileAssociationInfo" /> that provides specifics of the extension to be changed.</param>
        /// <param name="type"><see cref="PerceivedTypes" /> to be set that specifies Perceived Type of extension.</param>
        protected void SetPerceivedType(FileAssociationInfo file, PerceivedTypes type)
        {
            if (!file.Exists)
                throw new Exception("Extension does not exist");

            _registryWrapper.Write(file._extension, "PerceivedType", type.ToString());

            ShellNotification.NotifyOfChange();
        }
        /// <summary>
        ///     Determines of the list of extensions are associated with the specified program id.
        /// </summary>
        /// <param name="progId">Program id to check against.</param>
        /// <param name="extensions">String array of extensions to check against the program id.</param>
        /// <returns>String array of extensions that were not associated with the program id.</returns>
        public string[] CheckAssociation(string progId, params string[] extensions)
        {
            var notAssociated = new List<string>();

            foreach (var s in extensions)
            {
                var fai = new FileAssociationInfo(s);

                if (!fai.Exists || fai.ProgId != progId)
                    notAssociated.Add(s);
            }

            return notAssociated.ToArray();
        }
Beispiel #32
0
        /// <summary>
        ///     Gets or value that determines the <see cref="PerceivedType" />PerceivedType of the file.
        /// </summary>
        /// <param name="file"><see cref="FileAssociationInfo" /> that provides specifics of the extension to be changed.</param>
        /// <returns><see cref="PerceivedTypes" /> that specifies Perceived Type of extension.</returns>
        protected PerceivedTypes GetPerceivedType(FileAssociationInfo file)
        {
            if (!file.Exists)
                throw new Exception("Extension does not exist");

            var val = _registryWrapper.Read(file._extension, "PerceivedType");
            var actualType = PerceivedTypes.None;

            if (val == null)
                return actualType;

            try
            {
                actualType = (PerceivedTypes) Enum.Parse(typeof (PerceivedTypes), val.ToString(), true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

            return actualType;
        }
Beispiel #33
0
        /// <summary>
        ///     Set a value that indicates the name of the associated application with the behavior to handle this extension.
        /// </summary>
        /// <param name="file"><see cref="FileAssociationInfo" /> that provides specifics of the extension to be changed.</param>
        /// <param name="progId">Associated Program ID of handling program.</param>
        protected void SetProgId(FileAssociationInfo file, string progId)
        {
            if (!file.Exists)
                throw new Exception("Extension does not exist");

            _registryWrapper.Write(file._extension, string.Empty, progId);

            ShellNotification.NotifyOfChange();
        }