Ejemplo n.º 1
0
        /// <summary>
        /// 语言配置文件名
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public static string GetLanguageFile(string path)
        {
            if (ReadBoolean(TAG_CHECK_SYSLANG) && Directory.Exists(path))
            {
                Save(TAG_CHECK_SYSLANG, "false");
                string[] words   = CultureInfo.InstalledUICulture.EnglishName.Split(' ');
                string   syslang = words[0];
                string[] files   = Directory.GetFiles(path);
                foreach (string file in files)
                {
                    string name = MyPath.GetFullFileName(MyConfig.TAG_LANGUAGE, file);
                    if (string.IsNullOrEmpty(name))
                    {
                        continue;
                    }

                    if (syslang.Equals(name, StringComparison.OrdinalIgnoreCase))
                    {
                        Save(MyConfig.TAG_LANGUAGE, syslang);
                        break;
                    }
                }
            }
            return(MyPath.Combine(path, MyPath.GetFileName(MyConfig.TAG_LANGUAGE, GetAppConfig(TAG_LANGUAGE))));
        }
Ejemplo n.º 2
0
        public void TestGetFilename()
        {
            var p = new MyPath("/test/file.txt");

            Assert.AreEqual("file.txt", p.GetFileName());
            p = new MyPath("/test/folder");
            Assert.AreEqual("folder", p.GetFileName());
            p = new MyPath("/i/hope/test.is.over");
            Assert.AreEqual("test.is.over", p.GetFileName());
        }
Ejemplo n.º 3
0
        static void PathTest(string?path)
        {
            var possiblyNullPath = MyPath.GetFileName(path);

            Console.WriteLine(possiblyNullPath.Length); // Warning: Dereference of a possibly null reference

            if (!string.IsNullOrEmpty(path))
            {
                var goodPath = MyPath.GetFileName(path);
                Debug.Assert(goodPath != null);     //添加断言则不会有警告
                Console.WriteLine(goodPath.Length); // Safe!
            }
        }
Ejemplo n.º 4
0
        public void Init(string path)
        {
            this.Iscn2tw = false;

            //读取配置
            string tmp = MyPath.Combine(path, MyPath.GetFileName(MSEConfig.TAG, MyConfig.ReadString(MyConfig.TAG_MSE)));

            if (!File.Exists(tmp))
            {
                tmp = MyPath.Combine(path, MyPath.GetFileName(MSEConfig.TAG, FILE_CONFIG_NAME));
                if (!File.Exists(tmp))
                {
                    return;//如果默认的也不存在
                }
            }
            this.SetConfig(tmp, path);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 卡片信息配置文件名
 /// </summary>
 /// <param name="path"></param>
 /// <returns></returns>
 public static string GetCardInfoFile(string path)
 {
     return(MyPath.Combine(path, MyPath.GetFileName(MyConfig.TAG_CARDINFO, GetAppConfig(TAG_LANGUAGE))));
 }