C# 文件Copy 不包含.svn文件

今天遇到了C#文件copy的问题

现在写出了解决方案

        DirectoryInfo sourceDir = new DirectoryInfo(@"文件");
        DirectoryInfo destinationDir = new DirectoryInfo(@"文件");
        CopyDirectory(sourceDir, destinationDir);

       private static void CopyDirectory(DirectoryInfo source, DirectoryInfo destination)
        {
            if (!destination.Exists)
            {
                destination.Create();
            }
            FileInfo[] files = source.GetFiles();
            foreach (FileInfo file in files)
            {
                file.CopyTo(Path.Combine(destination.FullName, file.Name));
            }
            DirectoryInfo[] dirs = source.GetDirectories();
            foreach (DirectoryInfo dir in dirs)
            {
                if (!dir.Name.Contains(".svn"))
                {
                    string destinationDir = Path.Combine(destination.FullName, dir.Name);
                    CopyDirectory(dir, new DirectoryInfo(destinationDir));
                }

            }
        }

 希望对大家有用

你可能感兴趣的:(copy)