/// <summary>
        /// Opens a chm file and creates
        /// </summary>
        /// <param name="chmFile">full file path of the chm file to open</param>
        /// <param name="dmpInfo">dumping info</param>
        /// <remarks>If you call this method, all existing merged files will be cleared.</remarks>
        public void OpenFile(string chmFile, DumpingInfo dmpInfo)
        {
            if (File.Exists(chmFile))
            {
                _chmFiles.Clear();
                _toc.Clear();
                _index.Clear();
                _informationTypes.Clear();
                _categories.Clear();

                CHMFile newFile = new CHMFile(this, chmFile, dmpInfo);

                _toc   = new HtmlHelpToc(newFile.TOC);
                _index = new HtmlHelpIndex(newFile.IndexKLinks, newFile.IndexALinks);

                _chmFiles.Add(newFile);
                // add all infotypes and categories of the read file to this system instance
                MergeFileInfoTypesCategories(newFile);

                // check if the file has a merged files list
                if (newFile.MergedFiles.Length > 0)
                {
                    // extract the path of the chm file (usually merged files are in the same path)
                    FileInfo fi    = new FileInfo(chmFile);
                    string   sPath = fi.DirectoryName;

                    for (int i = 0; i < newFile.MergedFiles.Length; i++)
                    {
                        string sFile = newFile.MergedFiles[i];

                        if (sFile.Length > 0)
                        {
                            if (sFile[1] != ':')                            // no full path setting
                            {
                                sFile = Path.Combine(sPath, sFile);
                            }

                            MergeFile(sFile, dmpInfo, true);
                        }
                    }

                    if (newFile.MergLinks.Count > 0)
                    {
                        RecalculateMergeLinks(newFile);
                    }

                    RemoveMergeLinks();                     // clear all merge-links which have no target !
                }
            }
        }
        /// <summary>
        /// Merges a chm file to the current help contents
        /// </summary>
        /// <param name="chmFile">full file path of the chm file to merge</param>
        /// <param name="dmpInfo">dumping info</param>
        /// <param name="mergedFileList">true if the merge is done because a merged file list
        /// was found in the previously loaded CHM.</param>
        internal void MergeFile(string chmFile, DumpingInfo dmpInfo, bool mergedFileList)
        {
            if (File.Exists(chmFile))
            {
                if (_chmFiles.Count == 1)
                {
                    // if we open the first file, we directly point into the toc and index of this file.
                    // So that we don't merge the new toc's indexe's into the first file, we have to
                    // clone the internal arraylists first to a new instance of the toc/index holder classes.
                    IList <HtmlHelpTocItem>   atoc   = _toc.TOC;
                    IList <HtmlHelpIndexItem> alinks = _index.ALinks;
                    IList <HtmlHelpIndexItem> klinks = _index.KLinks;

                    _toc   = new HtmlHelpToc();
                    _index = new HtmlHelpIndex();

                    _toc.MergeToC(atoc);
                    _index.MergeIndex(alinks, IndexType.AssiciativeLinks);
                    _index.MergeIndex(klinks, IndexType.KeywordLinks);
                }

                CHMFile newFile = new CHMFile(this, chmFile, dmpInfo);

                if (mergedFileList)                // if we've called this method due to a merged file list merge
                {
                    RecalculateMergeLinks(newFile);

                    _toc.MergeToC(newFile.TOC, _chmFiles);
                    _index.MergeIndex(newFile.IndexALinks, IndexType.AssiciativeLinks);
                    _index.MergeIndex(newFile.IndexKLinks, IndexType.KeywordLinks);

                    _chmFiles.Add(newFile);

                    // add all infotypes and categories of the read file to this system instance
                    MergeFileInfoTypesCategories(newFile);
                }
                else
                {
                    _toc.MergeToC(newFile.TOC, _chmFiles);
                    _index.MergeIndex(newFile.IndexALinks, IndexType.AssiciativeLinks);
                    _index.MergeIndex(newFile.IndexKLinks, IndexType.KeywordLinks);

                    _chmFiles.Add(newFile);

                    // add all infotypes and categories of the read file to this system instance
                    MergeFileInfoTypesCategories(newFile);

                    // check if the file has a merged files list
                    if (newFile.MergedFiles.Length > 0)
                    {
                        // extract the path of the chm file (usually merged files are in the same path)
                        FileInfo fi    = new FileInfo(chmFile);
                        string   sPath = fi.DirectoryName;

                        for (int i = 0; i < newFile.MergedFiles.Length; i++)
                        {
                            string sFile = newFile.MergedFiles[i];

                            if (sFile.Length > 0)
                            {
                                if (sFile[1] != ':')                                // no full path setting
                                {
                                    sFile = Path.Combine(sPath, sFile);
                                }

                                MergeFile(sFile, dmpInfo, true);
                            }
                        }

                        //if(newFile.MergLinks.Count > 0)
                        //	RecalculateMergeLinks(newFile);

                        RemoveMergeLinks();                         // clear all merge-links which have no target !
                    }
                }
            }
        }