Possible Duplicate:
How to copy a file to another path?
I need to copy images from one folder to another folder when my code starts to execute. Every time it starts to execute this should be happen.
Possible Duplicate:
How to copy a file to another path?
I need to copy images from one folder to another folder when my code starts to execute. Every time it starts to execute this should be happen.
Public void CopyFiles(string sourcePath,string destinationPath)
{
string[] files = System.IO.Directory.GetFiles(sourcePath);
foreach(string file in files)
{
System.IO.File.Copy(sourcePath,destinationPath);
}
}
My take would be to use the following code -
public void CopyFiles(string sourcePath, string destinationPath)
{
string[] files = System.IO.Directory.GetFiles(sourcePath);
Parallel.ForEach(files, file =>
{
System.IO.File.Copy(file, System.IO.Path.Combine(destinationPath, System.IO.Path.GetFileName(file)));
});
}