110,535
社区成员
发帖
与我相关
我的任务
分享
static void Main(string[] args)
{
byte[] m_Temp = new byte[] { 1, 126, 83, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 1, 18, 0, 0, 0, 3, 0, 0 };
StreamWriter sw = File.AppendText("Text.txt");
for(int i = 0; i < m_Temp.Length; i ++)
{
WLog.WriteLine(i.ToString() + "," + m_Temp[i].ToString());
}
sw.Flush();
sw.Close();
sw.Dispose();
}
static void Main(string[] args)
{
string[] lines = File.ReadAllLines("aa.txt",Encoding.Default);
byte[] m_Temp = new byte[] { 1, 126, 83, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 1, 18, 0, 0, 0, 3, 0, 0 };
int n = 0;
n = Array.IndexOf(lines, "\"----------------BEGIN MEMORY MAP----------------\"");
if (n == -1) return;//错误
n++;//指向下一个
Regex regExp = new Regex(@"(\d+,)(\d+)", RegexOptions.Compiled);
Match m = Match.Empty;
for (int i = n; i < n + m_Temp.Length; i++)
{
m = regExp.Match(lines[i]);
if (!m.Success) break;//避免长度错误
lines[i] = regExp.Replace(lines[i], "${1}" + m_Temp[i - n].ToString());
}
File.WriteAllLines("bb.txt", lines);
Console.ReadKey();
}