关于修改txt文本文件内容
比如我的a.txt文本文件中的内容如下: 
 aaaaaa 
 bbbbbb 
 cccccc 
 dddddd 
 我希望用程序寻找到“bbbbbb”这行,然后把这行改成 "eeeeee "该怎么操作呢?难道把a.txt文件删掉,重新建一个a.txt,并且把新的内容写进去? 
 相当郁闷!
------解决方案--------------------用流打开,把修改后的字符流输进去
------解决方案--------------------为什么用文本,XML不是好很多么?   
 操作文本没什么好的办法 
 好像只能读出来然后修改然后保存
------解决方案--------------------StreamWriter
------解决方案--------------------最近遇到这样问题, 没有找到文件中替换的办法. 
 如果文件不是太大, 读出来, 替换掉,再写进去.   
 string s = null; 
                  using (StreamReader sr = new System.IO.StreamReader(strControlFile)) 
                     { 
                         s = sr.ReadToEnd(); 
                         s = s.Replace( "bbbbb ", "ddddd "); 
                     } 
   using (StreamWriter sw = new StreamWriter(strControlFile, false, Encoding.Default)) 
                     { 
                         sw.WriteLine(s); 
                     }
------解决方案--------------------只能是读取,修改,再保存
------解决方案--------------------1 将文件读到一个流或字符串 
 2 修改内容 
 3 将内容重新写入文件   
 如果你要修改中间的内容,好像没有其他方法了吧? 
------解决方案--------------------读取、替换、写入   
 using System; 
 using System.Collections.Generic; 
 using System.Text; 
 using System.IO;   
 namespace Test 
 { 
     class Program 
     { 
         static void Main(string[] args) 
         { 
             string strFile = @ "E:\test.txt "; 
             string line; 
             StreamReader sr = new StreamReader(strFile,System.Text.Encoding.Default); 
             line = sr.ReadToEnd(); 
             line = line.Replace( "bbbbbb ",  "eeeeee "); 
             sr.Close(); 
             StreamWriter sw = new StreamWriter(strFile,false); ; 
             sw.WriteLine(line); 
             sw.Close(); 
         } 
     } 
 }
------解决方案--------------------可用TextReader和TextWriter,简单一点,搜索一下MSDN中的列子