这篇文章介绍了拷贝整个目录下所有子目录及文件的代码
有需要的朋友可以参考一下
复制代码 代码如下:
Public Sub CopyDerictory(ByVal DirectorySrc As DirectoryInfo ByVal DirectoryDes As DirectoryInfo)
Dim strDirectoryDesPath As String = DirectoryDesFullName & "" & DirectorySrcName
If Not DirectoryExists(strDirectoryDesPath) Then
DirectoryCreateDirectory(strDirectoryDesPath)
End If
Dim f fs() As FileInfo
fs = DirectorySrcGetFiles()
For Each f In fs
FileCopy(fFullName strDirectoryDesPath & "" & fName True)
Next
Dim DirSrc Dirs() As DirectoryInfo
Dirs = DirectorySrcGetDirectories()
// 递归调用自身
For Each DirSrc In Dirs
Dim DirDes As New DirectoryInfo(strDirectoryDesPath)
CopyDerictory(DirSrc DirDes)
Next
End Sub
Private Sub Button_Click(ByVal sender As SystemObject ByVal e As SystemEventArgs) Handles ButtonClick
CopyDerictory(New DirectoryInfo("C:Documents and SettingsusernameFavorites") New DirectoryInfo("g: emp"))
End Sub