我有一个记录本txt文件内容格式如下
aaaaaaaa,bbbbbbbb,ccccccccc,dddddd通过下面这个方法可以以豆号为间隔读分别将值写入数组
 while ((input=sr.ReadLine())!=null)     
 {  
     string[] col=input.Split(',');                         
 }但是在记事本里用豆号分隔分麻烦要打一个豆号,想改成回车
也就TXT文件内容如下aaaaaa
bbbbbb
cccccc
dddddd那上面那个input.split(',') 就要改成 input.split('\t')  但是不行高大家帮改一下谢谢

解决方案 »

  1.   

    但是在记事本里用豆号分隔分麻烦要打一个豆号,想改成回车 
    也就TXT文件内容如下 aaaaaa 
    bbbbbb 
    cccccc 
    dddddd 
    现在你直接读取就可以 每行内容就是 不需要split了
      

  2.   

    while ((input=sr.ReadLine())!=null)    
    {  
    //就是input                       
    }
      

  3.   


    StreamReader sr=new StreamReader(路径);   
      string strLine = sr.ReadLine();   
      while(strLine!= null)   
      {   
          strLine = sr.ReadLine();   
      }
      

  4.   


    System.IO.StreamReader sr = System.IO.File.OpenText("D:/a.txt");
    String input;
    System.Collections.ArrayList al = new System.Collections.ArrayList();
    while ((input = sr.ReadLine()) != null)
    {
       al.Add(input);
    }
    string[] ary = new string[al.Count];
    al.CopyTo(ary);
      

  5.   

    using System.Text.RegularExpressions;
    using System.IO;StreamReader sr = new StreamReader(路径);
    string[] col = Regex.Split(sr.ReadToEnd(), @"\r\n");