C# 文件简繁体转换
简繁体转换:
1 class Program 2 { 3 static void Main(string[] args) 4 { 5 string strFilePath = @"E:\Demo\Simplifiled_Demo\files\test.txt"; 6 7 if (File.Exists(strFilePath)) 8 { 9 10 string strContent = File.ReadAllText(strFilePath, Encoding.UTF8); 11 12 foreach (var item in strContent) 13 { 14 if (item.Equals(‘帐‘)) 15 { 16 //简体转繁体; 17 var ss = "账"; 18 strContent = Regex.Replace(strContent, item.ToString(), ss); 19 return; 20 } 21 } 22 File.WriteAllText(strFilePath, strContent); 23 24 Console.WriteLine("OK"); 25 Console.ReadKey(); 26 27 } 28 } 29 }