'源和目标路径必须具有相同的根。移动不会跨卷运行 [英] 'Source and destination path must have identical roots. Move will not work across volumes
问题描述
我想将所有.emb文件从pendrive(驱动器i :)移动到名为To(C:\ To)的文件夹。我在EmbFile中获取所有.emb文件,但是当我想要移动这些文件时,我收到错误('源和目标路径必须具有相同的根。移动将无法跨卷工作)尝试了很多但没有得到解决。任何人都可以帮助我。
i我在下面提到了我的代码。
什么我试过了:
Imports System.IO
Public Class FRM_Main
私有子FRM_Main_Load(发件人为对象,e为EventArgs)处理MyBase.Load
Dim Copy_From As String = 我:
Dim Copy_To As String =C:\ To
尝试
昏暗EmbFiles = Directory.EnumerateFiles(Copy_From,*。Emb,SearchOption.AllDirectories)
每个currentFile作为字符串在EmbFiles中
Dim fileName = currentFile.Substring(Copy_From.Length + 1)
Directory.Move(Path.Combine(currentFile,fileName),Path.Combine(Copy_To,fileName))
下一页
赶上Ex Exception
Console.WriteLine(Ex.Message)
结束尝试
结束子
结束类
I want to move all .emb file from pendrive (drive i:) to folder called To (C:\To) . i am getting all .emb file in EmbFile but when i am tying to move thid files i am getting error ('Source and destination path must have identical roots. Move will not work across volumes) Tried a lot but not getting solved. can anyone help me out of it.
i have mentioned my code below.
What I have tried:
Imports System.IO
Public Class FRM_Main
Private Sub FRM_Main_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim Copy_From As String = "I:"
Dim Copy_To As String = "C:\To"
Try
Dim EmbFiles = Directory.EnumerateFiles(Copy_From, "*.Emb", SearchOption.AllDirectories)
For Each currentFile As String In EmbFiles
Dim fileName = currentFile.Substring(Copy_From.Length + 1)
Directory.Move(Path.Combine(currentFile, fileName), Path.Combine(Copy_To, fileName))
Next
Catch Ex As Exception
Console.WriteLine(Ex.Message)
End Try
End Sub
End Class
推荐答案
我想将所有.emb文件从pendrive(驱动器i :)移动到名为To的文件夹(C:\\ \\ toTo)。
I want to move all .emb file from pendrive (drive i:) to folder called To (C:\To) .
不,这是不可能的。移动是一项特殊操作,只能在同一个硬盘上工作。
基本上移动是复制+删除的特殊情况。
标准操作是
No, it is impossible. Move is a special operation that can only work on same hdd.
Basically a move is a special case of copy+delete.
The standard operation is
copy source to target
delete source
当源和目标在相同的卷上时,技术技巧允许如果没有文件的真实副本,那就是移动。
it happen that when source and target are on same volume, a technical trick allow you to do it without a real copy of the files, that is the move.
这篇关于'源和目标路径必须具有相同的根。移动不会跨卷运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!