温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

文件夹及其子文件夹Copy VB.NET

发布时间:2020-04-30 02:13:37 阅读:703 作者:mathed001 栏目:编程语言
Private Sub CopyDir(ByVal srcPath As StringByVal aimPath As String)          Try              ' 检查目标目录是否以目录分割字符\结束,如果不是则添加之              If aimPath.Substring(aimPath.Length - 1) <> Path.DirectorySeparatorChar Then                  aimPath += Path.DirectorySeparatorChar              End If               '判断源目录是否存在,不存在则退出.              If (Not Directory.Exists(srcPath)) Then Exit Sub               '' 判断目标目录是否存在如果不存在则新建之              'If (Not Directory.Exists(aimPath)) Then Directory.CreateDirectory(aimPath)               ' 得到源目录的文件列表,该里面是包含文件以及目录路径的一个数组              Dim fileList() As String = Directory.GetFileSystemEntries(srcPath)              ' 遍历所有的文件和目录               For Each FileName As String In fileList                  ' 先当作目录处理如果存在这个目录就递归Copy该目录下面的文件                  If Directory.Exists(FileName) Then                      If (Not Directory.Exists(aimPath + Path.GetFileName(FileName))) Then Directory.CreateDirectory(aimPath + Path.GetFileName(FileName))                      CopyDir(FileName, aimPath + Path.GetFileName(FileName))                      ' 否则直接Copy文件                  Else                      File.Copy(FileName, aimPath + Path.GetFileName(FileName), True)                  End If              Next           Catch ex As Exception              Response.Write("<br>" + ex.ToString())          End Try      End Sub 
向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI