如何将datetimepicker与getfile一起使用

时间:2017-09-26 06:08:06

标签: c# winforms

        string Date1 = dateTimePicker1.Value.ToString("ddMM");

    foreach (string file in Directory.GetFiles(@"C:\tbank_file\out\", "*.txt"))
    {
        MessageBox.Show(file);
    }

我想在getfile的循环foreach中使用变量date1

2 个答案:

答案 0 :(得分:0)

 string Date1 = dateTimePicker1.Value.ToString("ddMM");

    foreach (string file in Directory.GetFiles(@"C:\tbank_file\out\", "*.txt"))
    {
        MessageBox.Show(file+" "+ Date1);
    }

答案 1 :(得分:0)

foreach (string file in Directory.GetFiles(@"C:\tbank_file\out\", "*.txt"))
    {
        MessageBox.Show(file+" "+ dateTimePicker1.Value.ToString("dd/MM/yyyy"););
    }