kcwallace Posted February 2, 2007 Posted February 2, 2007 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); } } Quote Go Beavs!!!
Leaders snarfblam Posted February 2, 2007 Leaders Posted February 2, 2007 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. Quote [sIGPIC]e[/sIGPIC]
kcwallace Posted February 2, 2007 Author Posted February 2, 2007 All I am trying to do is copy a list of folders from one place on the network to another. on a periodic basis. Quote Go Beavs!!!
Leaders snarfblam Posted February 2, 2007 Leaders Posted February 2, 2007 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. Quote [sIGPIC]e[/sIGPIC]
SonicBoomAu Posted February 7, 2007 Posted February 7, 2007 This forum link might help you with the code Quote 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
mskeel Posted February 8, 2007 Posted February 8, 2007 This tool might be helpful as well. It was built for just this purpose. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.