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)); } } }
?希望对大家有用
1 楼 yangelhun 2011-11-18 木有pathfilter么 2 楼 chenhailong 2011-11-19 yangelhun 写道木有pathfilter么