vb如何向别的计算机发送文件夹,VB怎样复制文件夹?(包括里面的文件)

满意答案

给你一个列子

sourcePath 为源文件地址

targetPath 存放文件的地址

'复制文件夹到指定位置

Function CopyDir(ByVal sourcePath As String, ByVal targetPath As String) As Boolean

Try

'检查目标目录是否以目录分隔符结束,不是则添加

If Microsoft.VisualBasic.Right(targetPath, 1) <> "" Then targetPath += System.IO.Path.DirectorySeparatorChar

'判断目标目录是否存在,不存在则新建

If Not Directory.Exists(targetPath) Then Directory.CreateDirectory(targetPath)

'得到源目录的文件列表,该文件裏面是包含文件以及目录路径的一个数组

Dim fileList As String() = Directory.GetFileSystemEntries(sourcePath)

'遍历所有的文件和目录

For Each filepath As String In fileList

'目录处理,递归

If (Directory.Exists(filepath)) Then

CopyDir(filepath, targetPath + Path.GetFileName(filepath))

Else

'复制文件

File.Copy(filepath, targetPath + Path.GetFileName(filepath), True)

End If

Next

Return True

Catch ex As Exception

Return False

End Try

End Function

希望对你有所帮助·····

00分享举报

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值