以下是复制单个文件的方法
FileInfo fi1 = new FileInfo(xmlFileName);
FileInfo fi2 = new FileInfo(xmlfile);
if (File.Exists(xmlFileName))
{
fi1.Delete();
}
//Copy
fi2.CopyTo(xmlFileName);
以下复制文件夹的方法,文件夹到文件夹,并替换相同的文件
if (File.Exists(xmlfile))//必须判断要复制的文件是否存在
{
File.Copy(xmlfile, xmlFileName, true);//三个参数分别是源文件路径,存储路径,若存储路径有相同文件是否替换
}