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());

  

上一篇:在浏览器中输入URL并回车后都发生了什么?


下一篇:BGP-6,解决IBGP的水平分割