HI ,
I want to copy files from one folder with all extension to another folder .
How do i achieve this.
For example : I've files with names like bs.txt, bs.mmx, bs.git ,bs.yrt ( some extension for reference) now i want to copy all the files with bs name ( what ever may be the extensions) ...i tried system.io.file copy method using *.* at the end but it fails...
Can anybody guide how to achieve it..
Regards,
Bsraju

HOW to : Copy files with all extensions
ayeli
Thanks for the solution..but if the files are there in destination directory how do i achieve as there is no option to replace the old files.
PrashanthSpark
In that case you'll want to use the overload of CopyTo that takes "bool overwrite"
as its second parameter and pass true to it.
-Shawn
Michel
DirectoryInfo dir = new DirectoryInfo(directoryName);
foreach (FileInfo file in dir.GetFiles("bs*.*"))
{
file.CopyTo(Path.Combine(newDirectory, file.Name));
}