Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

 

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);

               }
           }

Go Beavs!!!
  • Leaders
Posted
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.
[sIGPIC]e[/sIGPIC]
  • Leaders
Posted
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 isn't is because all that is necessary in order to move a directory is a simple change in the FAT (which can't 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.
[sIGPIC]e[/sIGPIC]
Posted
This forum link might help you with the code

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

-- Rick Cook, The Wizardry Compiled

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...