Main Site Documentation

Copying a directory


#1

Hello, I have managed to copy some files between thumb drives using the handy file.copy command. However, I cannot locate a copy command for a directory. Does anyone know if this exists?

I know I can write a routine that would scan through all the directories that would make the appropriate directories and individually copy the files, however, I am not a big fan of re-inventing the wheel if someone else has already put in the effort to make this routine.

Regards,
Aaron


#2

http://msdn.microsoft.com/en-us/library/cc148994.aspx

Adapt as needed.


#3

These is no copy only move. If you want to copy a directory and it’s contents you’ll need to write the recursive method yourself. Shouldn’t be too difficult though.


#4

Thanks for the info, interesting that the algorithm you linked has some syntax I never knew existed

foreach (string s in files)
            {

Learn something new every day! ;D


#5

foreach’s are very slow, on an embedded system use a for loop.