Copy Directories accross VOlumes

kcwallace

Well-known member
Joined
May 27, 2004
Messages
172
Location
Irvine, CA
Can someone point me to a solution for copying files accross two volumes?

I am using the code below. You can see the iterations I tried.

C#:
foreach (DirectoryInfo diNext in dirs)
            {
                if (diNext.LastWriteTime < cutOffDate)
                {
                    //dinext.Move(fromPath + diNext.Name, toPath + diNext.Name);
                    //diNext.MoveTo(toPath + diNext.Name);
                    Directory.Move(fromPath + diNext.Name, toPath + diNext.Name);

                }
            }
 
What specifically are you trying to do? It seems like you are trying to use file specific features on a folder (DirectoryInfo does not support features such as size and access dates). Are you trying synchronize two folders (I see that you are comparing dates)? If so, your best bet might be to use a method that recurses through directories and examines and copies each file individually.
 
Well, like I said, many operations are only available on a per-file basis, so you will probably have to roll your own folder-copying function that works on file-by-file internally. I am aware that there is a Directory.Move method, but there function to copy a directory. I think there should be one, but the reason that there isnt is because all that is necessary in order to move a directory is a simple change in the FAT (which cant be done directly in DotNet code), but to copy a directory, the OS simply does a file-by-file copy, which you can do for yourself.
 
Back
Top