Create() public method

Creates actual extension association key in registry for the specified extension and supplied attributes.
public Create ( string progId ) : FileAssociationInfo
progId string Name of expected handling program.
return FileAssociationInfo
コード例 #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
ファイル: AssociationManager.cs プロジェクト: unixcrh/Motion
        /// <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 (string s in extensions)
            {
                FileAssociationInfo fai = new FileAssociationInfo(s);

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

                fai.ProgID = progId;
            }
        }
コード例 #3
0
ファイル: AssociationManager.cs プロジェクト: zhuangyy/Motion
        /// <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 (string s in extensions)
             {
            FileAssociationInfo fai = new FileAssociationInfo(s);

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

            fai.ProgID = progId;
             }

             ProgramAssociationInfo pai = new ProgramAssociationInfo(progId);

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

             pai.AddVerb(new ProgramVerb("open", executablePath));
        }
コード例 #4
0
ファイル: AssociationManager.cs プロジェクト: unixcrh/Motion
        /// <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 (string s in extensions)
            {
                FileAssociationInfo fai = new FileAssociationInfo(s);

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

                fai.ProgID = progId;
            }

            ProgramAssociationInfo pai = new ProgramAssociationInfo(progId);

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

            pai.AddVerb(new ProgramVerb("open", executablePath));
        }
コード例 #5
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;
        }
コード例 #6
0
ファイル: AssociationManager.cs プロジェクト: zhuangyy/Motion
        /// <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 (string s in extensions)
             {
            FileAssociationInfo fai = new FileAssociationInfo(s);

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

            fai.ProgID = progId;
             }
        }