[转]C# 实现对文件夹及其子文件夹的整体复制
2009-08-08 17:48
441 查看
Code
1 private void CopyFiles(string strSouPath, string strDesPath)
2 {
3 Directory.CreateDirectory(strDesPath);
4
5 if (!Directory.Exists(strSouPath)) return;
6
7 string[] directories = Directory.GetDirectories(strSouPath);
8
9 if (directories.Length > 0)
10 {
11 foreach (string d in directories)
12 {
13 CopyFiles(d, strDesPath + d.Substring(d.LastIndexOf("\\")));
14 }
15 }
16
17 string[] files = Directory.GetFiles(strSouPath);
18
19 if (files.Length > 0)
20 {
21 foreach (string s in files)
22 {
23 File.Copy(s, strDesPath + s.Substring(s.LastIndexOf("\\")));
24 }
25 }
26 }
1 private void CopyFiles(string strSouPath, string strDesPath)
2 {
3 Directory.CreateDirectory(strDesPath);
4
5 if (!Directory.Exists(strSouPath)) return;
6
7 string[] directories = Directory.GetDirectories(strSouPath);
8
9 if (directories.Length > 0)
10 {
11 foreach (string d in directories)
12 {
13 CopyFiles(d, strDesPath + d.Substring(d.LastIndexOf("\\")));
14 }
15 }
16
17 string[] files = Directory.GetFiles(strSouPath);
18
19 if (files.Length > 0)
20 {
21 foreach (string s in files)
22 {
23 File.Copy(s, strDesPath + s.Substring(s.LastIndexOf("\\")));
24 }
25 }
26 }
相关文章推荐
- C#实现把指定文件夹下的所有文件复制到指定路径下以及修改指定文件的后缀名
- C#实现本地复制文件或者文件夹建立副本取名功能
- 复制文件夹及其子文件夹的内容(还是自己写的容易理解)
- 在C#中如何实现文件夹的复制(转)
- C#.NET实现文件夹的复制
- c#实现复制全部文件夹及文件的代码
- C#实现复制文件夹中文件到另一个文件夹的方法
- c# 复制文件夹及其文件
- 递归调用实现命令行中以树状结构展现特定的文件夹及其子文件夹
- C++删除文件夹及其子文件夹中的文件功能实现(Unicode)
- C#.NET实现文件夹的复制
- php删除与复制文件夹及其文件夹下所有文件的实现代码
- 复制一个文件夹下所有文件(包括子文件夹)并修改文件后缀名 java实现加密文档unlock
- 在C#中如何实现文件夹的复制(转)
- C#复制或删除文件夹(及文件夹下所有子文件夹和文件)、获取文件所在文件夹、二进制读取文件相关
- c#实现将一个文件夹中的所有文件复制到另一个文件夹,并在新文件夹中创建一个txt文件记录copy的文件综述以及文件名称
- c#如何实现对指定路径文件夹的遍历并复制里面所有文件到指定路径
- 使用某个文件夹下的所有文件去替换另一个文件夹下及其子文件夹下存在的同名文件(Python实现)
- C# 复制文件,文件夹以及子文件夹文件
- 用C#写的小工具,可以将当前文件夹及其子文件夹内的所有文本文件转换为utf-8编码格式。