VB.NET拷贝整个目录下所有子目录及文件的实例代码_asp.net教程-查字典教程网
VB.NET拷贝整个目录下所有子目录及文件的实例代码
VB.NET拷贝整个目录下所有子目录及文件的实例代码
发布时间:2016-12-29 来源:查字典编辑
摘要:复制代码代码如下:PublicSubCopyDerictory(ByValDirectorySrcAsDirectoryInfo,ByVal...

复制代码 代码如下:

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()

// 递归调用自身

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

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新asp.net教程学习
    热门asp.net教程学习
    编程开发子分类