復(fù)制代碼 代碼如下:
Public Sub CopyDerictory(ByVal DirectorySrc As DirectoryInfo, ByVal DirectoryDes As DirectoryInfo)
Dim strDirectoryDesPath As String = DirectoryDes.FullName "" DirectorySrc.Name
If Not Directory.Exists(strDirectoryDesPath) Then
Directory.CreateDirectory(strDirectoryDesPath)
End If
Dim f, fs() As FileInfo
fs = DirectorySrc.GetFiles()
For Each f In fs
File.Copy(f.FullName, strDirectoryDesPath "" f.Name, True)
Next
Dim DirSrc, Dirs() As DirectoryInfo
Dirs = DirectorySrc.GetDirectories()
// 遞歸調(diào)用自身
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: emp"))
End Sub
您可能感興趣的文章:- VB.net常用字符和日期等函數(shù)
- vb.net讀寫文件代碼
- vb.net發(fā)布水晶報表程序步驟
- VB.net 查詢獲取數(shù)據(jù)庫數(shù)據(jù)信息
- VB.net讀取Word文檔屬性的方法
- VB.NET進(jìn)度條的方法代碼
- 獲取客戶端IP地址c#/vb.net各自實(shí)現(xiàn)代碼
- asp.net(vb.net)獲取真實(shí)IP的函數(shù)
- asp.net 驗(yàn)證碼的簡單制作(vb.net+C#)
- 在VB.NET應(yīng)用中使用MySQL的方法
- vb.net操作注冊表的方法分析【增加,修改,刪除,查詢】