///   <summary>
///   <c> 方法 </c> 将指定文件夹复制到指定的文件目录下
///   </summary>
///   <param   name= "aimPath "> 目标文件目录 </param>
///   <param   name= "srcPath "> 源文件目录 </param>
private   void   dataBackup(string   aimPath   ,string   srcPath)
{
if(aimPath[aimPath.Length   -   1]   !=   Path.DirectorySeparatorChar)
aimPath   +=   Path.DirectorySeparatorChar;

if(!Directory.Exists(aimPath))  
Directory.CreateDirectory(aimPath);

string[]   fileList   =   Directory.GetFileSystemEntries(srcPath);
foreach(string   file   in   fileList)
{
//   先当作目录处理如果存在这个目录就递归Copy该目录下面的文件
if(Directory.Exists(file))
dataBackup(aimPath+Path.GetFileName(file),file);
//   否则直接Copy文件
else
File.Copy(file,aimPath+Path.GetFileName(file),true);
}
}

相关文章:

  • 2021-11-06
  • 2021-12-24
  • 2022-12-23
  • 2021-08-04
  • 2022-12-23
  • 2021-06-23
猜你喜欢
  • 2021-10-10
  • 2022-12-23
  • 2021-12-16
  • 2022-12-23
  • 2022-12-23
  • 2021-12-10
  • 2022-01-13
相关资源
相似解决方案