C# copy folder and files from source path to target path
static void Main(string[] args)
{
string sourceDir = @"E:\SourcePath";
string destDir = @"E:\Dest";
CopyDirectoriesFiles(sourceDir, destDir);
Console.ReadLine();
} public static void CopyDirectoriesFiles(string sourceDirectory, string targetDirectory)
{
var diSource = new DirectoryInfo(sourceDirectory);
var diTarget = new DirectoryInfo(targetDirectory);
CopyAll(diSource, diTarget);
} public static void CopyAll(DirectoryInfo source, DirectoryInfo target)
{
Directory.CreateDirectory(target.FullName); // Copy each file into the new directory.
foreach (FileInfo fi in source.GetFiles())
{
Console.WriteLine(@"Copying {0}\{1}", target.FullName, fi.Name);
fi.CopyTo(Path.Combine(target.FullName, fi.Name), true);
} // Copy each subdirectory using recursion.
foreach (DirectoryInfo diSourceSubDir in source.GetDirectories())
{
DirectoryInfo nextTargetSubDir =
target.CreateSubdirectory(diSourceSubDir.Name);
CopyAll(diSourceSubDir, nextTargetSubDir);
}
}
C# copy folder and files from source path to target path的更多相关文章
- [PowerShell] Backup Folder and Files Across Network
## This Script is used to backup folder/files and delete the old backup files. ## Author: Stefanie # ...
- [转]COPY OR MOVE FILES AND FOLDERS USING OLE AUTOMATION
本文转自:http://sqlindia.com/copy-move-files-folders-using-ole-automation-sql-server/ I love playing aro ...
- gen already exists but is not a source folder. Convert to a source folder or rename it.
异常提示: gen already exists but is not a source folder. Convert to a source folder or rename it. 错误原因 ...
- 在Eclipse工具里创建maven的web工程,在建立src/main/java包出现The folder is already a source folder.解决
1. 与创建普通java工程一样,点击右键找到New菜单,在弹出的界面输入maven ---->>点击maven Project------>>点击next 2 进入下一个界 ...
- 使用maven新建类目录是,报错The folder is already a source folder.的解决办法
转自:https://www.cnblogs.com/loger1995/p/6539139.html 我们有时候新建一个webapp的maven项目时,生成的目录结构是这样子的: 缺少maven规范 ...
- maven出错The folder is already a source folder
右键build path -> configure build path -> source ,选择 src/main/java.src/test/java删除,然后再新建.
- The folder is already a source folder
不知为啥,创建了一个maven项目后,发现只有src/main/resources这个资源文件夹,然后,右键新建 Source Folder 时提示 “The folder is already a ...
- depth: working copy\infinity\immediates\files\empty
depth: working copy\infinity\immediates\files\empty 有时间,需要整理下,svn 合并深度这四项:具体的意思.
- 出现The folder is already a source folder
右键build path -> configure build path -> source ,选择 src/main/java.src/test/java删除,然后再新建.
随机推荐
- ajax请求成功,状态却是200
AJAX状态为200,这类状态代码表明服务器成功地接受了客户端请求.简单的来说成功发送一个AJAX请求,但是就是不进入success事件,进入error事件. $.ajax({ type:'POST' ...
- Docker 02 - 向 Docker 的 Tomcat 镜像中部署 Web 应用
目录 1 下载 Docker 镜像 2 部署Web项目 2.1 通过Dockerfile自定义项目镜像 2.2 启动自定义镜像, 生成一个容器 2.3 另一种启动方式: 交互式启动 3 (附) 向镜像 ...
- 简单http和https服务器python脚本
欢迎加入python学习交流群 667279387 工作经常要用到测试http和https协议,这里写了两个简单的脚本实现简单的http服务器和https服务器. http服务器代码 import s ...
- bug小结
在不同的文件下面可以创建同一个包,但是不能创建同一个class文件!!! ParameterType:需要写实体类的类型,最好不要写实体的别名 这是因为我们在配置mybatis的配置文件时已经说明 ...
- jQuery操作元素对象的样式
在jQuery中操作元素为了加快速度,或者书写速度,可以用到json的格式: <!DOCTYPE html> <html> <head> <meta char ...
- HTML5基础 实例
<!DOCTYPE html><html> <head> <title>李清照简介</title> </head> <bo ...
- 笔记||Python3之对象的方法
什么是对象的方法? python中的一切类型的数据都是对象. 对象:数据和方法 对象数据:如 a = 'sfd' 对象方法:其实就是属于该对象的函数 对象的方法调用:对象.方法 字符串对象常用的方法: ...
- Day 05 文本处理和爬虫基础1
目录 什么是文件 什么是文本 如何通过文本编辑器控制.txt文件 打开文件的三种模式 t和b模式 高级应用 文本处理 + 词云分析 效果如下 爬虫原理 requests模块 re模块 爬取图片 爬取视 ...
- 大数据项目2(Java8聚合操作)
前言:为很好的理解这些方法,你需要熟悉java8特性Lambda和方法引用的使用 一:简介 我们用集合的目的,往往不是简单的仅仅把数据保存哪里.而是要检索(遍历)或者去计算或统计....操作集合里面的 ...
- [系列] Go 使用 defer 函数 要注意的几个点
概述 defer 函数大家肯定都用过,它在声明时不会立刻去执行,而是在函数 return 后去执行的. 它的主要应用场景有异常处理.记录日志.清理数据.释放资源 等等. 这篇文章不是分享 defer ...