我得到了这段代码,我试图复制一些 doc 文件,同时创建 dir 结构。
Private Sub btn_CopiarFiles_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_CopiarFiles.Click Dim itemChecked As Object Const quote As String = """"
For Each itemChecked In chklist_extensiones.CheckedItems
For Each archivo In Directory.GetFiles("C:\TestDirectory1", itemChecked.ToString(), SearchOption.AllDirectories)
If File.Exists(archivo) Then
Dim InfoArchivo As FileInfo = My.Computer.FileSystem.GetFileInfo(archivo)
Dim InfoDirectorio As DirectoryInfo = InfoArchivo.Directory
File.Copy(archivo, _
Path.Combine("C:\TestDirectory2\" + Path.GetFileName(InfoDirectorio.FullName) + "\", Path.GetFileName(archivo)), True)
End If
Next
Next
End Sub
问题是,而不是复制 from:
C:\TestDirectory1\document.doc
to C:\TestDirectory2\document.doc
C:\TestDirectory1\doc1\document1.doc
to C:\TestDirectory2\doc1\document1.doc
C:\TestDirectory1\doc1\doc2\document2.doc
toC:\TestDirectory2\doc1\doc2\document2.doc
是否以这种方式复制和创建目录
C:\TestDirectory1\document.doc
to C:\TestDirectory2\TestDirectory1\document.doc
C:\TestDirectory1\doc1\document1.doc
toC:\TestDirectory2\doc1\document1.doc
C:\TestDirectory1\doc1\doc2\document2.doc
C:\TestDirectory2\doc2\document2.doc
我很确定修复有点简单,但我真的看不到它......
你们中有人看到我的代码有什么问题吗?
谢谢