AFAIK, there's no method in the .NET Framework or the VB runtime library which can do this 'out of the box'. We'll therefore need to write a custom method:
using System;
using System.IO;
class Test
{
static void Main()
{
string sourceDir = "c:\\whatever";
string destDir = "c:\\whatever2";
CopyDirectory(sourceDir, destDir, "xls");
}
static void CopyDirectory(string sourceDir, string destDir, string extension)
{
string[] filePaths = Directory.GetFiles(sourceDir, "*." + extension);
if (!Directory.Exists(destDir))
{
Directory.CreateDirectory(destDir);
}
foreach(string filePath in filePaths)
{
string fileName = Path.GetFileName(filePath);
File.Copy(filePath, String.Format("{0}\\{1}", destDir, fileName));
}
}
}