-3

6 か月以上前のファイルの数 (カウント) を返すコードを書きたいと思います。

すべてのファイルを返す以下のスクリプトがあります

どんな助けでも大歓迎です

以下のコード

// check the number of file in the CPS directory on S drive
private void btnCheck_Click(object sender, EventArgs e)
{
    {
        listBox1.Items.Clear();
        {
        }

        string[] files = System.IO.Directory.GetFiles(@"S:\CPS Papers\"); // @"S:\CPS Papers\" C:\test\

        this.listBox1.Items.AddRange(files);
        textBox1.Text = listBox1.Items.Count.ToString();
        {
        }
    }
}
4

2 に答える 2

0

おそらくデータ構造が必要です

public class FileInfo 
{
    // .. member declaring age of a file :D (lets say Age)
}

File インスタンス (ファイル) のコレクションを取得できた場合は、linq 式を使用できます。

var result = from file in files where file.Age > 6 select file;
于 2013-05-14T16:03:00.857 に答える