码迷,mamicode.com
首页 > 其他好文 > 详细

功能代码_复制文件

时间:2015-07-16 18:27:02      阅读:78      评论:0      收藏:0      [点我收藏+]

标签:

private static void CopyDir(DirectoryInfo origin, string target)
        {
            if (!target.EndsWith("\\"))
            {
                target += "\\";
            }
            if (!Exist(target))
            {
                Create(target);
                //Create(target, origin.GetAccessControl());
            }
            FileInfo[] fileList = origin.GetFiles();
            DirectoryInfo[] dirList = origin.GetDirectories();
            foreach (FileInfo fi in fileList)
            {
                File.Copy(fi.FullName, target + fi.Name, true);
            }
            foreach (DirectoryInfo di in dirList)
            {
                CopyDir(di, target + di.Name);
            }
            DirectoryInfo tmp = new DirectoryInfo(target);
            tmp.Attributes = origin.Attributes;
            tmp.SetAccessControl(origin.GetAccessControl());
        }

 


     

功能代码_复制文件

标签:

原文地址:http://www.cnblogs.com/HF520134/p/4651567.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!