解决方案 »

  1.   

    这个只是字符串数据处理,挨着遍历所有航,把每行都处理一下就新行了,具体代码参考如下            //具体操作
                string[] fileLines = File.ReadAllLines("file path");
                StreamWriter sw = new StreamWriter("file path", false, Encoding.UTF8);
                int i = 1;
                foreach (string s in fileLines)
                {
                    string[] s2 = s.Split(',');
                    sw.WriteLine("J"+i+",1,"+s2[2]+","+s2[3]);
                    sw.Flush();
                }
                sw.Close();
      

  2.   

    string.Split(',')
    拆分
    重新拼接
      

  3.   

    你要说明,上面的txt  编辑成下面的txt要做哪些处理,
    这才是最重要的
      

  4.   

    其实你完全可以把逗号都替换成tab
    然后整个粘进excel里,处理起来就方便了
    处理完了,再粘回来,然后替换回逗号就行了完全没必要开发什么程序来处理这东西
    每次要处理的内容不一样,逻辑就要来回来回的改,很难适用多种情况
    而且只用一次,这程序没什么存在的价值
      

  5.   

    不知道你需要的更改后的第二列1是否是固定的,还有第四列的37是否是固定的,如果不是的话,下面的代码相应修改一下。using System;
    using System.IO;namespace CVSParser
    {
    class Program
    {
    public static void Main(string[] args)
    {
    Parser();
    Console.Write("Press any key to continue . . . ");
    Console.ReadKey(true);
    }

    public static void Parser()
    {
    char[] delimiters = new char[] { ',' };
    using (StreamReader reader = new StreamReader("demo.txt"))
    {
    while (true)
    {
    string line = reader.ReadLine();
    if (line == null)
    {
    break;
    }
    string[] parts = line.Split(delimiters);
    // Console.WriteLine("{0} field(s)", parts.Length);
    Console.WriteLine("J{0},{1},{2},37{3}", parts[0], 1, parts[3], parts[2]);
    }
    }
    }
    }
    }
      

  6.   

    两步分,每行读取和每行写入,以下请参考
              string SourcePath=textBox1.Text;
                string DestinationPath = textBox2.Text;            DirectoryInfo Directory = new DirectoryInfo(SourcePath);            foreach (FileInfo file in Directory.GetFiles())
                {   
                 
                StreamReader sr = new StreamReader(SourcePath + file.Name);
                string[] lines = File.ReadAllLines(SourcePath + file.Name);
                int a = 0;
                string Combina="";            List<string> needs = new List<string>();
                foreach(string line in lines)
                {
             //取值
                    }     
                       
                }
     public static void WriteInTxt(string DestinationPath,List<string> needs)
            {
                string WriteInPath = DestinationPath;
                int NumberCount =needs.Count;
                int i=0;            if (!File.Exists(WriteInPath))
                {
                    FileStream fs1 = new FileStream(WriteInPath, FileMode.Create, FileAccess.Write);//创建写入文件        
                    StreamWriter sw = new StreamWriter(fs1);
                    for(i = 0;i < NumberCount ; i++)
                    {                    sw.WriteLine(needs[i]);//开始写入值  
                    }
                        
                    sw.Close();
                    fs1.Close();
                }
                else
                {
                    FileStream fs = new FileStream(WriteInPath, FileMode.Open, FileAccess.Write);
                    StreamWriter sr = new StreamWriter(fs);
                    for (i = 1; i < NumberCount; i++)
                    {                    sr.WriteLine(needs[i]);//开始写入值                  }  
                    sr.Close();
                    fs.Close();
                }
      

  7.   

    来凑数的:sr.WriteLine(needs[i]);这个估计行
      

  8.   

    CSDN真是一个万能的平台,9,10楼的人真是热心人阿