根据日期 读取三个csv不留指定日期的内容 新保存一个文件

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
using ConsoleApplication1;
using log4net;

namespace ISC.LPCheck.HashValue
{
    static class Program
    {
        static void Main()
        {
            string title = "日付";
            string str1 = "2016年10月12日";
            DateTime dt1 = Convert.ToDateTime(str1);
            string str3 = "2016年7月12日";
            DateTime dt3 = Convert.ToDateTime(str3);
            int index = 1;
           
            List<string> newList = new List<string>();
 
            foreach (var file in Directory.GetFiles(@"C:\ECsystem\Pv_Click\download\csv\20161019"))
            {
                foreach (var item in File.ReadAllLines(file, Encoding.UTF8))
                {

                    if (item.Contains(title) && index == 1)
                    {
                        newList.Add(item); //添加title
                    }
                    else if(!item.Contains(title))
                    {
                        var hitukistr = item.Split(',')[0].Replace("\"", "");
                        DateTime dt2 = Convert.ToDateTime(hitukistr);
                        if (DateTime.Compare(dt1, dt2) >= 0 && DateTime.Compare(dt2, dt3) >= 0)
                        {
                            newList.Add(item);
                        }
                    }
                    Console.WriteLine(item);
                    index++;
                }
            }
            File.WriteAllLines(@"C:\ECsystem\Pv_Click\download\csv\20161019\test1.csv", newList.ToArray(), Encoding.UTF8);

        }

    }
}

上一篇:CSS中盒子模型


下一篇:矩阵连乘问题的算法复杂度的计算--卡塔兰数(Catalan数)的数学推导和近似公式