The documentation doesn't say anything about it and I don't have any way to test it right n开发者_运维知识库ow. It does say it about File.Move
which makes me think File.Copy
might not work across different volumes.
This is related to this other problem I'm having.
Just tested it, it works. Just use:
File.Copy(@"C:\File.txt", @"E:\File.txt");
I agree it is weird this isn't mentioned in the documentation though.
There's no reason you can't copy a file across volumes. When performing a "move" operation, you're either doing a "rename" (when moving to the same volume) or "copy" then "delete" (when moving across volumes). Obviously a copy operation has to be able to work across volumes.
Note that the documentation you linked to for File.Move
says:
This method works across disk volumes
So I don't know what your issue is.
Yes, it works.
Note that moving a file is a different operation than copying it. When you move a file inside its volume the OS just changes the pointer to that file, it doesn't have to read and write all data. Copying a file or moving it out of its volume does require that, and that is probably the cause of that comment.
精彩评论