1

I have an FTP location contains files created daily basis.I need to take the files created today.Files are like

test-tester2016060720001.xml.zip    /todays one
test-tester2016060620001.xml.zip
test-tester2016060520001.xml.zip

I need a logic in c# to get file name contains todays date ie test-tester2016060720001.xml.zip for today

peter
  • 8,158
  • 21
  • 66
  • 119

1 Answers1

5

This might do what you need.

var filePattern = String.Format("test-tester{0}*.xml.zip", DateTime.Today.ToString("yyyyMMdd"));

DirectoryInfo d = new DirectoryInfo(@"D:\Test");
FileInfo[] Files = d.GetFiles(filePattern);

foreach(FileInfo file in Files )
{
  //Do what you want with the file
}
ThiagoPXP
  • 5,362
  • 3
  • 31
  • 44