Пример #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)
        {
            FileAssociationInfo 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);
        }
Пример #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();
            }

            RegistryKey root = Registry.ClassesRoot;

            root.CreateSubKey(file._extension);
        }
Пример #3
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)
        {
            FileAssociationInfo 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;
        }
Пример #4
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();
            }

            RegistryKey root = Registry.ClassesRoot;

            root.CreateSubKey(file._extension);
        }
Пример #5
0
        private static void RegisterFileType(string extensionType)
        {
            string id = "ilSFV-" + extensionType.ToUpper();
            FileAssociationInfo fai = new FileAssociationInfo("." + extensionType.ToLower());
            if (fai.Exists)
                fai.Delete();
            fai.Create(id);

            string path = Assembly.GetExecutingAssembly().Location;

            ProgramAssociationInfo pai = new ProgramAssociationInfo(fai.ProgID);
            if (pai.Exists)
                pai.Delete();

            pai.Create
            (
                string.Format("{0} File", extensionType.ToUpper()),
                new ProgramVerb("Open", path + " \"%1\"")
            );

            /*RegistryWrapper reg = new RegistryWrapper();
            reg.Write(string.Format(@"{0}\shell\ilSFV", id), "MUIVerb", "ilSFV");
            reg.Write(string.Format(@"{0}\shell\ilSFV", id), "MultiSelectModel", "Single");
            reg.Write(string.Format(@"{0}\shell\ilSFV", id), "SubCommands", "ilsfv.verify");*/
        }