We can copy files from one folder to another folder using SharePoint object model in SharePoint 2010.
SPWeb site = SPContext.Current.Web;
SPFolder folder = site.GetFolder("Source folder name");
SPFileCollection spFileCollection = folder.Files;
List<SPFile> lstFiles = new List<SPFile>(spFileCollection .Count);
//Get all the files from the folder and put it in a list of type SPFile
foreach (SPFile file in spFileCollection)
{
lstFiles.Add(file);
}
//The below code will take a file and move to the destination folder. it will continue till the end of all the files in the list
foreach (SPFile singleFile in listFiles)
{
singleFile.MoveTo("Destination foldername/" +singleFile.Name, true);
}
You can also check SharePoint 2010 Articles and SharePoint Jobs.
SPWeb site = SPContext.Current.Web;
SPFolder folder = site.GetFolder("Source folder name");
SPFileCollection spFileCollection = folder.Files;
List<SPFile> lstFiles = new List<SPFile>(spFileCollection .Count);
//Get all the files from the folder and put it in a list of type SPFile
foreach (SPFile file in spFileCollection)
{
lstFiles.Add(file);
}
//The below code will take a file and move to the destination folder. it will continue till the end of all the files in the list
foreach (SPFile singleFile in listFiles)
{
singleFile.MoveTo("Destination foldername/" +singleFile.Name, true);
}
You can also check SharePoint 2010 Articles and SharePoint Jobs.