首页 > 代码库 > MakeCode 递归生成资源文件
MakeCode 递归生成资源文件
static void yieldDir(DirectoryInfo dir, int depth, StringBuilder sb1, StringBuilder sb2) { var firstFlag = ""; var firstFlag1 = ""; var dirtmp = dir; for (int a = 0; a < depth; a++) { var dirtmpname = Regex.Replace(dirtmp.Name, @"[^\w]", "_"); firstFlag = string.Concat(dirtmp.Name, @"\", firstFlag); firstFlag1 = string.Concat(dirtmpname, @"_", firstFlag1); dirtmp = dirtmp.Parent; } foreach (var f11 in dir.GetFiles()) { var f = f11.Name; var f1 = Regex.Replace(f, @"[^\w]", "_"); sb1.Append($@" <data name=""{firstFlag1}{f1}"" type=""System.Resources.ResXFileRef, System.Windows.Forms""> <value>..\Resources\{firstFlag}{f};System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value> </data>"); sb2.Append($@"loc1.Add(new BuildInfo(string.Concat(CONST.corePath, @""Common\{firstFlag}{f}""), Deflate.Compress(Properties.Resources.{firstFlag1}{f1})));"); } foreach(var d11 in dir.GetDirectories()) { yieldDir(d11, depth + 1, sb1, sb2); } } var dir = new DirectoryInfo(@"C:\Users\Administrator\Desktop\mc(core+mysql)\Server\Resources\CSRedis"); StringBuilder sb1 = new StringBuilder(); StringBuilder sb2 = new StringBuilder(); yieldDir(dir, 1, sb1, sb2); File.WriteAllText(@"test.txt", sb1.ToString() + sb2.ToString());
MakeCode 递归生成资源文件
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。