tag:blogger.com,1999:blog-21172681.post203068194357801872..comments2023-10-25T23:39:10.162+13:00Comments on Software Development and stuff: Recursively Copying files in C#KiwiBastardhttp://www.blogger.com/profile/06464945422472093454noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-21172681.post-18285677938251605262009-07-09T11:07:55.808+12:002009-07-09T11:07:55.808+12:00I tried using this code, is it possible to add fil...I tried using this code, is it possible to add files from more than one directory path?<br /><br />Like say for instance i have a set of files in one directory (D:\data1) and a set of files in other directory (D:\Data2) can i copy them all to a third folder<br /> (D:\data3)? When I attempt to do this I get an error.YesManhttps://www.blogger.com/profile/12008486053822983433noreply@blogger.comtag:blogger.com,1999:blog-21172681.post-90252962923578638382008-06-24T01:31:00.000+12:002008-06-24T01:31:00.000+12:00the resulting program misses the files in the root...the resulting program misses the files in the rootDir.<BR/><BR/>change BuildWithFiles to<BR/><BR/> ///<BR/> /// Get Sub Dirs and Files of a root directory<BR/> ///<BR/> private void BuildFileListWithFiles(string rootDir)<BR/> {<BR/> // get files in current directory<BR/> string[] files = Directory.GetFiles(rootDir);<BR/> _dirList.AddRange(files);<BR/> // Iterate through all directories<BR/> string[] subdirectoryEntries = Directory.GetDirectories(rootDir);<BR/> foreach (string subdirectory in subdirectoryEntries)<BR/> {<BR/> BuildFileListWithFiles(subdirectory);<BR/> }<BR/> }<BR/><BR/>will also copy all files inside the rootDir<BR/><BR/>Nice solution btw.Anonymousnoreply@blogger.com