Example #1
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);
        }
Example #2
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);
            }
        }
Example #3
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);
        }
Example #4
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;
        }