参考StreamReader.ReadLine 方法

解决方案 »

  1.   

    文本一行一行读出来.
    然后对每行进行处理,方法有很多,在最后加两个逗号,
    或者用string.Replace()把3个逗号换成5个逗号
      

  2.   

    text1.text=text1.text & ",,"
      

  3.   

    try一行一行读的内存里,并在末尾加两个逗号,最后将内存里的行集回写即可...
      

  4.   

    查看StreamReader,StreamWriter类,里面有例子啊
      

  5.   

    System.IO.FileStream fs = new FileStream(@"c:\dw.txt",FileMode.Open);
    System.IO.StreamReader sr = new StreamReader(fs);
    string input;
    while ((input=sr.ReadLine())!=null) 
    {
    string strTmp = sr.ReadLine();
    Response.Write(strTmp+"<br>");
    }
    ---------------------------------------
    这样来搞定,但输出来的中文是乱码
      

  6.   

    你页可以这样:string path = @"c:\temp\MyTest.txt";        try 
            {
                if (File.Exists(path)) 
                {
                    File.Delete(path);
                }             using (StreamReader sr = new StreamReader(path)) 
                {
                    string x = sr.ReadToEnd();
                    x = x.Replace("\r\n",",,\r\n");
                    sr.Close();
                    sr.Dispose();
    using (StreamWriter sw = new StreamWriter(path)) 
                {
                                    sw.WriteLine(x);
    sw.Close();            }                 
                }
            } 
            catch (Exception e) 
            {
                Console.WriteLine("The process failed: {0}", e.ToString());
            }
      

  7.   

    System.IO.StreamReader sr = new StreamReader(fs,Encoding.Default);
      

  8.   

    System.IO.StreamReader sr = new StreamReader(fs, System.Text.Encoding.Default);orSystem.IO.StreamReader sr = new StreamReader(fs, System.Text.Encoding.GetEncoding("GB2312"));
      

  9.   

    using System;
    using System.IO;
    using System.Text;
    public class MakeFile
    {
        static string path = @"D:\CSharp\Basic\File.txt";
        public static void Main()
        {
            StringBuilder res = new StringBuilder();
            using(StreamReader reader = new StreamReader(path, Encoding.GetEncoding("GB2312")))
            {
                string line = "";
                while((line = reader.ReadLine()) != null)    
                {
                     line += ",,\n";
                     res.Append(line);   
                }
            }
            Console.Write(res.ToString()); 
            Console.Read();
        }
        
    }
      

  10.   

    System.IO.FileStream fs = new FileStream(@"c:\dw.txt",FileMode.Open);
    System.IO.StreamReader sr = new StreamReader(fs, System.Text.Encoding.GetEncoding("GB2312"));
    string input;
    while ((input=sr.ReadLine())!=null) 
    {
    string strTmp = sr.ReadLine();
           strTmp = strTmp + ",,";
    Response.Write(strTmp+"<br>");
    }
    --------------------------------------------------------------
    这样可以,但现在我想通过strTmp = strTmp + ",,";转化后立即覆盖原来的dw.txt文件,该如何实现,谢谢
      

  11.   

    StreamWriter sw = new StreamWriter(path)就可以,但要有匿名写的权限
      

  12.   

    net_lover(孟子E章) 老大:
    StreamWriter sw = new StreamWriter(path)
    这样好像不行呢
      

  13.   

    你要把StreamWriter 结合FileReader 和FileWriter来用
    或者好象有专门的file类吧
    我没用过,但原来接触过
    你自己看一下
      

  14.   

    text.Text=text.Text & ",,"
      

  15.   

    replace(",,,",",,,,,")不就可以了嘛?