Page 1 of 1

[SOLVED] relocate entire folder

Posted: Mon Nov 10, 2003 8:43 am
by yaron
Hello all,

I want to write a function that will get a current path and destination path and wil relocate an entire folder to the destination path.
I know how to move a file but not a folder that may contain subfolders as well.

any ideas?
Thanks

Posted: Mon Nov 10, 2003 9:04 am
by yaron
btw it runs under win 2000

Posted: Mon Nov 10, 2003 9:13 am
by JayBird
i presume there isn't a move dir function.

You will probably need to take the following steps.

Traverse the directory you want to move, and create a replica directory structure in your intended destination.

Whilst traversing and creating the directory structure, you'll need to list the files, and moves them as you come across them.

Mark

Posted: Mon Nov 10, 2003 9:40 am
by yaron
hmm...
I was afraid of that... because my source dir can contain subdirs so i need to write some recursion which is a bad thing to do...

Posted: Mon Nov 10, 2003 10:12 am
by Jean-Yves
To move a folder and its subfolders, you could try (eg):

Code: Select all

system("move c:\\folder1\\folder3 c:\\folder3");
Seems to work ok for me under Win2K.

Posted: Mon Nov 10, 2003 10:41 am
by yaron
thanks a lot!!!
it is working!!!!!