。 如果有一个目录AA,里面有15个文本文件,我如何取出文件生成时间满足某个时间段范围的该文本文件名。
2. 如何在一个文本文件中查找某个字符,看是否存在。比如字符”AA"在某个文本文件内容中是否存在。

解决方案 »

  1.   

    1\不知
    2\读出txt内容,然后 内容.IndexOf("AA")!=-1 就是不存在,否则存在
      

  2.   

    DirectoryInfo di = new DirectoryInfo(filepath);
            FileInfo[] fis = di.GetFiles("*.txt");
            for(int i=0;i<fis.Length;i++)
            {
                if(fis[i].CreationTime <DateTime.Now)
                {
                    //fis[i].Name 文件名
                }
            }2.
            StreamReader m_streamReader = new StreamReader(filepathname, System.Text.Encoding.GetEncoding("gb2312"));
            string filestr = m_streamReader.ReadToEnd();
            m_streamReader.Close();
            if(filestr.IndexOf("AA")>=0)
            {
                //存在
            }
      

  3.   


    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.IO;namespace WindowsFormsApplication15
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        private void button1_Click(object sender, EventArgs e)
            {
                string[] htms = Directory.GetFiles("c:\\abc");
                List<wenjian> list_wenjian=new List<wenjian>();
                foreach (string wj in Directory.GetFiles("c:\\abc"))
                {
                    list_wenjian.Add(new wenjian { name = wj, time = File.GetLastWriteTime(wj) }); //.GetCreationTime(wj) });
                }            var tiaojian_fj = from wenjian wj in list_wenjian
                                  where (wj.time > DateTime.Parse("2009-04-08")) && (wj.time < DateTime.Parse("2009-05-01"))
                                  select wj;
                List<wenjian> list_wenjian1=new List<wenjian>(tiaojian_fj.ToArray());
                this.Text = list_wenjian1.Count.ToString();
                
            }
        }    class wenjian
        {
            public string name;
            public DateTime time;
        }
    }你的第一个问题,第二个就是用indexofhttp://www.mystruggle.com.cn
      

  4.   

    string[] htms = Directory.GetFiles("c:\\abc");
    多余了