拷贝整个目录下所有子目录及文件的方法,拷贝整个目录下所有子目录及文件的方法
【 tulaoshi.com - ASP.NET 】
Public Sub CopyDerictory(ByVal DirectorySrc As DirectoryInfo, ByVal DirectoryDes As DirectoryInfo)
If Not Directory.Exists(strDirectoryDesPath) Then
Directory.CreateDirectory(strDirectoryDesPath)
End If
Dim f, fs() As FileInfo
fs = DirectorySrc.GetFiles()
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com) For Each f In fs
File.Copy(f.FullName, strDirectoryDesPath & "" & f.Name, True)
Next
Dim DirSrc, Dirs() As DirectoryInfo
Dirs = DirectorySrc.GetDirectories()
'递归调用自身
For Each DirSrc In Dirs
Dim DirDes As New DirectoryInfo(strDirectoryDesPath)
CopyDerictory(DirSrc, DirDes)
Next
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
CopyDerictory(New DirectoryInfo("C:Documents and SettingsusernameFavorites"), New DirectoryInfo("g:temp"))
End Sub
来源:http://www.tulaoshi.com/n/20160129/1490495.html
看过《拷贝整个目录下所有子目录及文件的方法》的人还看了以下文章 更多>>