Exemple #1
0
        /// <summary> 从流中读取文件 </summary>
        public void ReadFromStream()
        {
            string strTemp = string.Empty;

            if (string.IsNullOrEmpty(Path.GetExtension(this.FilePath)))
            {
                this.FilePath = this.FilePath.Trim() + KeyConfiger.SimONExtend;
            }


            //  打开子文件并读取子文件关键字内容
            using (FileStream fileStream = new FileStream(FilePath, FileMode.Open, FileAccess.Read))
            {
                //using (StreamReader streamRead = new StreamReader(fileStream, System.Text.Encoding.GetEncoding("GB2312")))
                using (StreamReader streamRead = new StreamReader(fileStream, System.Text.Encoding.Default))
                {
                    while (!streamRead.EndOfStream)
                    {
                        //  直接调用基类读取方法
                        base.ReadKeyLine(streamRead);
                    }
                }
            }

            if (this.Keys.Count == 0)
            {
                return;
            }

            //  触发最后一个关键字的构造
            BaseKey lastKey = this.Keys.Last();

            if (lastKey.BuilderHandler != null)
            {
                lastKey.BuilderHandler(lastKey, lastKey);
            }
        }