zoukankan      html  css  js  c++  java
  • Copy指定目录下的所有文件到新位置

    public void CreateAllDirOrFiles(string oldPath, string newPath)
     {
      string[] strfiles = Directory.GetFiles(oldPath);
      foreach (string f in strfiles)
      {
       string strFullPath = newPath + "\\" + Path.GetFileName(f);
       if (!Directory.Exists(newPath))
       {
        Directory.CreateDirectory(newPath);
       }
       try
       {
        File.Copy(f, strFullPath,true);
       }
       catch (Exception exp)
       {
        throw exp;
       }
      }
      string[] strDirs = Directory.GetDirectories(oldPath);
      foreach (string dir in strDirs)
      {
       int pos = dir.LastIndexOf("\\");
       string strDirName = dir.Substring(pos + 1, dir.Length - pos - 1);
       string strTempOldPath = oldPath + "\\" + strDirName;
       string strTempNewPath = newPath + "\\" + strDirName;
       CreateAllDirOrFiles(strTempOldPath, strTempNewPath);
      }
     }
  • 相关阅读:
    Python-手动安装第三方包
    SQL SERVER-根据jobID查job
    python-包模块等概念
    锁表
    Python-try异常捕获
    胶水语言
    C++之多态性与虚函数
    android
    开源许可协议
    hal
  • 原文地址:https://www.cnblogs.com/snlfq2000/p/1786314.html
Copyright © 2011-2022 走看看