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删除,然后再新建.
随机推荐
- WebGPU学习(三):MSAA
大家好,本文学习MSAA以及在WebGPU中的实现. 上一篇博文 WebGPU学习(二): 学习"绘制一个三角形"示例 下一篇博文 WebGPU学习(四):Alpha To Cov ...
- 深入理解Android异步消息处理机制
一.概述 Android 中的异步消息处理主要分为四个部分组成,Message.Hndler.MessageQueue 和 Looper.其关系如下图所示: 1. Message 是线程之间传递的消息 ...
- 在阿里云购买SSL证书,让网站支持HTTPS
SSL简介 引自:https://baike.baidu.com/item/ssl/320778?fr=aladdin SSL SSL(Secure Sockets Layer 安全套接层),及其继任 ...
- iOS导出远程推送所需要的P12 或pem文件
http://www.saitjr.com/ios/ios-export-remote-notification-p12-pem-file.html iOS导出远程推送所需要的P12 或pem文件 h ...
- 如何手动实现TryInsert和InsertOrUpdate
在日常开发中,我们有时会需要对数据的插入操作进行定制.比如,如果表里已有某某记录就不写入新纪录,或者表里没该记录就插入,否则就更新.前者我们称为TryInsert,后者为InsertOrUpdate( ...
- koa安装教程
此安装是在windows下进行 1.全局安装 npm install -g koa-generator 安装成功后会出现以下信息 创建项目 koa2 -e koa2-learn 2.1 -e指的是使用 ...
- python爬虫获取天猫与京东的商品价格
git地址: https://gitee.com/zhxs_code/spider_python 目前已简单实现可以爬取指定页面的价格(天猫和狗东的都可以),但是由于天猫与狗东对价格的展示方式和策 ...
- 基于TCP协议之SSH
#SSH客户端 import socket # 1. 创建符合TCp协议的手机 client = socket.socket(socket.AF_INET,socket.SOCK_STREAM) # ...
- 学习Python编程技术的流程与步骤,自学与参加培训学习都适用
一.清楚学习目标 无论是学习什么知识,都要有一个对学习目标的清楚认识.只有这样才能朝着目标持续前进,少走弯路,从学习中得到不断的提升,享受python学习计划的过程. 虽然目前的编程语言有很多,但是 ...
- appium+java(八)获取Toast内容信息
前言 Appium中很经典的问题了,在两年前也就是2017年3月6号07:22分,我才看到appium1.6.3版本的发布,更新内容为Ios上可以实现Toast的获取,而Windows也就是安卓端,还 ...