zoukankan      html  css  js  c++  java
  • 文件拼接快速批处理文件

    遇到一个问题,有三个word文档,要求每个文档里提取一条信息和另外的word文档组合,形成一条新的信息,存入txt文件。

     1  path q = new path();//path类,用来存放路径;
     2         public string wenti(int i, int l) //提取第i行的问题,从wenti l.txt提取;
     3         {
     4             StreamReader wenti = new StreamReader(""+q.questionpath+"wenti" + l + ".txt", Encoding.GetEncoding("GB2312"));
     5             string sLine = "";
     6             ArrayList wentiList = new ArrayList();
     7             while (sLine != null)
     8             {
     9                 sLine = wenti.ReadLine();
    10                 if (sLine != null && !sLine.Equals(""))
    11                     wentiList.Add(sLine);
    12             }
    13             wenti.Close();
    14             string wenti2 = (string)wentiList[i];
    15             return wenti2;
    16         }
    17         public string daan(int i, int l)//提取第i行答案,从daanl.txt提取;
    18         {
    19             StreamReader daan = new StreamReader("" + q.questionpath + "daan" + l + ".txt", Encoding.GetEncoding("GB2312"));
    20             string[] daan1 = daan.ReadLine().ToString().Split('^');
    21 
    22             daan.Close();
    23             return daan1[i];
    24           
    25         }
    26         public string duihua(int i, int l)//提取i行信息,从duihual.txt读取;
    27 { 28 StreamReader duihua = new StreamReader("" + q.questionpath + "duihua" + l + ".txt", Encoding.GetEncoding("GB2312")); 29 string sLine = ""; 30 ArrayList duihualist = new ArrayList(); 31 while (sLine != null) 32 { 33 sLine = duihua.ReadLine(); 34 if (sLine != null && !sLine.Equals("")) 35 duihualist.Add(sLine); 36 } 37 duihua.Close(); 38 string duihua2 = (string)duihualist[i]; 39 return duihua2; 40 } 41 int i = 0; 42 public void greatfile(int id, int l) 43 { 44 FileStream px = new FileStream(""+q.questionpath+"" + id + ".txt", FileMode.Create); 45 StreamWriter file = new StreamWriter(px, Encoding.Default); 46 47 file.WriteLine("" + id + "^" + wenti(i, l) + "" + daan(i, l) + "^" + duihua(i, l) + "^" + id + ""); 48 49 file.Close(); 50 px.Close(); 51 i++; 52 }

    先把每个word文档用到的信息提取出来,再通过程序批处理这些问题。

  • 相关阅读:
    项目总结
    个人博客
    个人博客
    个人博客
    个人博客
    个人博客
    个人博客
    个人博客
    个人博客
    浅谈Vue与swiper轮播图框架结合小案例
  • 原文地址:https://www.cnblogs.com/wandd/p/2701705.html
Copyright © 2011-2022 走看看