日期:2014-05-18 浏览次数:20835 次
string tempStr = File.ReadAllText(@"C:\Documents and Settings\Administrator\桌面\Test.txt", Encoding.GetEncoding("GB2312"));//读取tx string search_str = "0x10010"; string replace_str = "N"; string pattern = @"(?i)[^,,]+(?=\s*?[,,]\s*?" + search_str + ")"; tempStr = Regex.Replace(tempStr, pattern, replace_str);//替换 File.WriteAllText(@"C:\Documents and Settings\Administrator\桌面\Test.txt",tempStr, Encoding.GetEncoding("GB2312"));//写回
------解决方案--------------------
readline,然后存为string,用string的split按“,”号分割为string数组,第7个string为0x10010的既要查找的行,然后再修改第6个string.
存储就不需要说了吧?