c# - Copy All Files/Subdirectories In a File to Another -


i trying copy folder source destination. source , destination folder in same directory. structure of folder vary each copy, needs generic. folder contain files, , subdirectories need copied over. in entire contents of 1 folder should copied no matter contains folder.

i hope isnt vauge. quick example of i'm looking for: source folder path: c:\directories\versions\11.0.2 destination folder path: c:\directories\versions\11.0.3

copy of 11.0.2 contents 11.0.3

here code have isn't effective:

//create of directories foreach (string dirpath in directory.getdirectories(sourcedir, "*", searchoption.alldirectories)) directory.createdirectory(dirpath.replace(sourcedir, targetdir));  //copy files foreach (string newpath in directory.getfiles(sourcedir, "*.*", searchoption.alldirectories)) file.copy(newpath, newpath.replace(sourcedir, targetdir)); 

any ideas of how accomplish this?

well msdn example

this example demonstrates how use i/o classes synchronously copy contents of directory location. in example, user can specify whether copy subdirectories. if subdirectories copied, method in example recursively copies them calling on each subsequent subdirectory until there no more copy.

you have at

asynchronous file i/o

asynchronous operations enable perform resource-intensive i/o operations without blocking main thread. performance consideration particularly important in windows store app or desktop app time-consuming stream operation can block ui thread , make app appear if not working.


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -