C# copy source directory files with original folder to the destination path
private static void PathCopyFilesWithOriginalFolder()
{
int sourceFilesNum = ;
try
{
string sourceDir = @"E:\Source";
string destDir = @"E:\Dest";
string[] allSourceFiles = Directory.GetFiles(sourceDir, "*", SearchOption.AllDirectories);
if (allSourceFiles != null && allSourceFiles.Any())
{
foreach (var sourceFileFullName in allSourceFiles)
{
string sourceFileDir = Path.GetDirectoryName(sourceFileFullName);
string sourceFileRelativeDir = string.Empty;
if (sourceFileDir.Length > sourceDir.Length)
{
sourceFileRelativeDir = sourceFileDir.Substring(sourceDir.Length + );
}
else
{
sourceFileRelativeDir = "";
}
string destFileDir = Path.Combine(destDir, sourceFileRelativeDir);
if (!Directory.Exists(destFileDir))
{
Directory.CreateDirectory(destFileDir);
} string destFileFullName = Path.Combine(destFileDir, Path.GetFileName(sourceFileFullName));
File.Copy(sourceFileFullName, destFileFullName, true);
string msg = $"SourceFileFullName:{sourceFileFullName},DestFileFullName:{destFileFullName}";
Console.WriteLine(msg);
sourceFilesNum++;
}
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
System.Diagnostics.Debug.WriteLine(sourceFilesNum);
}
}
C# copy source directory files with original folder to the destination path的更多相关文章
- [转]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 ...
- convert source code files to pdf format in python
import os import sys def find_file(root_dir, type): dirs_pool = [root_dir] dest_pool = [] def scan_d ...
- angular.copy(source, destination)
angular.copy(source, destination)只有1个参数,返回source的深拷贝有2个参数source的深拷贝复制给destination
- depth: working copy\infinity\immediates\files\empty
depth: working copy\infinity\immediates\files\empty 有时间,需要整理下,svn 合并深度这四项:具体的意思.
- mysql配置文件夹错误:在安装mysql 5.6.19 时运行cmake命令是出现CMake Error: The source directory does not appear to contai
在安装mysql 5.5.xx 时运行cmake命令是出现CMake Error: The source directory does not appear to contain CMakeLists ...
- 解决Cannot find config.m4 Make sure that you run '/home/php/bin/phpize' in the top level source directory of the module
oot@DK:/home/daokr/downfile/php-7.0.0/ext/mysqlnd# /home/php/bin/phpizeCannot find config.m4. Make s ...
- how to recursively all files in a folder with sudo permissions in macOS
how to recursively all files in a folder with sudo permissions in macOS write bug OK sudo chmod 777 ...
- C# copy files from source directory to destination file and rename repeated files and does not override
static void CopyFiles() { string sourceDir = @"D:\C\ll"; string destDir = @"D:\LL&quo ...
- [转]How to Use xp_dirtree to List All Files in a Folder
本文转自:http://www.sqlservercentral.com/blogs/everyday-sql/2012/11/13/how-to-use-xp_dirtree-to-list-all ...
随机推荐
- PAT-2019年秋季考试-甲级
7-1 Forever (20 分) #include <bits/stdc++.h> using namespace std; int N,K,m,number[10]; multima ...
- 自古逢秋悲寂寥,奈何今秋热成雕?Python使用Pyecharts统计全国温度Top10并绘图
秋词-刘禹锡 自古逢秋悲寂寥, 我言秋日胜春朝. 晴空一鹤排云上, 便引诗情到碧霄. 古人谈及秋天,都是悲凉寂寥,那么-.我好想回到古代的秋天啊!明明到了秋天,为什么最近的气温比夏天还热. 之前做天气 ...
- SpringBoot-HelloWorld(三)
HelloWorld 学一个新的框架,不写helloworld是没有灵魂的,嘿嘿 准备工作 我们将学习如何快速的创建一个Spring Boot应用,并且实现一个简单的Http请求处理.通过这个例子对S ...
- 《手把手教你》系列进阶篇之2-python+ selenium自动化测试 - python基础扫盲(详细教程)
1. 简介 这篇文章主要是分享讲解一下,如何封装自己用到的方法和类.以便方便自己和别人的调用,这样就可以避免重复地再造轮子. 封装(Encapsulation)是面向对象的三大特征之一(另外两个是继承 ...
- 数据库Oracle函数之单行函数的介绍
函数介绍: 函数:是数据库产品中提供的能够处理查询结果的方法. 函数能够用于下面的目的: • 执行数据计算 • 修改单个数据项 • 格式化显示的日期和数字 • 转换列数据类型 • 函数有输入参数,并且 ...
- CoderForces Round54 (A~E)
ProblemA Minimizing the String 题目链接 题解:这一题读完题就写了吧.就是让你删除一个字母,使得剩下的字符组成的字符串的字典序最小:我们只要第一个当前位置的字符比下一个字 ...
- 最新设计打样制作完成的FPGA视频开发板VIP—V101
设计目的:1.摄像头驱动(30w-500w mipi接口)2.VGA显示器驱动3.USB2.0视频采集4.tft液晶接口(ttl.lvds驱动)5.视频.图像处理(算法验证)6.各种视频接口处理(av ...
- 【Oracle】ORA-12560: TNS: 协议适配器错误
问题现象: ORA-12560: TNS: 协议适配器错误 解决方法: 启动监听服务
- 递归的实际业务场景之MySQL 递归查询
喜欢就点个赞呗! 源码<--请点击此处查看 引入 当我看到一些评论时,例如下面的样子.我挺好奇这个功能是怎么样做出来的.进过查阅资料,发现这其实是 MySQL 的递归操作.下面就让我操作一下怎么 ...
- ruby 使用 rqrcode 生成二维码
参考: https://github.com/whomwah/rqrcode 1. gem 'rqrcode' 2. 在helper中: require 'base64' def generat ...