Example #1
0
        public static List <YML> ReadFile(string filename)
        {
            string EngPath = StaticVars.DIREN + filename;
            string ChnPath = StaticVars.DIRCNen + filename;

            FileExistInfo finfo = IsFileExistInfo(ChnPath);

            if (!finfo.IsExist)
            {
                FileStream fs   = File.Create(ChnPath);
                Byte[]     info = new UTF8Encoding(true).GetBytes("l_english:");
                fs.Write(info, 0, info.Length);
                fs.Close();
            }
            // 检测chn文件夹内文件是否存在,不存在则建立。

            List <string> listEng = new List <string>(File.ReadAllLines(EngPath));

            if (EngPath.Contains("simp_chinese.yml"))
            {
                ChnPath = ChnPath.Replace("simp_chinese.yml", "english.yml");
            }
            List <string> listChn = new List <string>(File.ReadAllLines(ChnPath));

            return(BuildYMLList(listEng, listChn));
        }
Example #2
0
        public static FileExistInfo IsFileExistInfo(string filename)
        {
            FileExistInfo finfo = new FileExistInfo()
            {
                FileName = filename, IsExist = false
            };

            if (File.Exists(finfo.FileName))
            {
                finfo.IsExist = true;
                return(finfo);
            }

            finfo.FileName = finfo.FileName.Replace("english.yml", "l_simp_chinese.yml");
            if (File.Exists(finfo.FileName))
            {
                finfo.IsExist = true;
                return(finfo);
            }

            finfo.FileName = finfo.FileName.Replace("l_simp_chinese.yml", "l_english.yml");
            if (File.Exists(finfo.FileName))
            {
                finfo.IsExist = true;
                return(finfo);
            }
            finfo.FileName = filename;
            return(finfo);
        }