File.Copy 可以从一个卷复制到另一个卷吗?
文档对此没有任何说明,我也没有现在没有任何方法可以测试它。它确实说明了 文件.移动
这让我觉得 File.Copy
可能无法在不同的卷上工作。
这与此其他相关我遇到的问题。
The documentation doesn't say anything about it and I don't have any way to test it right now. 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
刚刚测试过,它有效。只需使用:
我同意文档中没有提到这一点很奇怪。
Just tested it, it works. Just use:
I agree it is weird this isn't mentioned in the documentation though.
您没有理由不能跨卷复制文件。执行“移动”操作时,您要么执行“重命名”(移动到同一卷时),要么执行“复制”然后“删除”(跨卷移动时)。显然,复制操作必须能够跨卷工作。
请注意,您链接到的 File.Move 文档说:
所以我不知道您的问题是什么。
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: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.