您的位置:首页 > 编程语言 > VB

How to Copy an Entire Directory in VB6?

2005-08-27 00:35 661 查看
Sub Copy(ByVal SourcePath As String, ByVal DestinationPath As String)
'拷贝指定目录下所有文件到另一位置
'by VBDN 2005-8-26 http://blog.csdn.net/vbdn/
'注意:SourcePath,DestinationPath这两个目录一定要存在,否则会出错
'使用举例: Copy "c:/temp", "c:/a" 将会把目录c:/temp下所有文件拷贝到c:/a下
Dim sFile As String
SourcePath = Replace(SourcePath & "/", "//", "/")
DestinationPath = Replace(DestinationPath & "/", "//", "/")
sFile = Dir(SourcePath, vbNormal Or vbHidden Or vbArchive Or vbReadOnly)
Do While Len(sFile) > 0
Debug.Print SourcePath & sFile, DestinationPath & sFile
FileCopy SourcePath & sFile, DestinationPath & sFile
sFile = Dir '下一个文件
Loop
End Sub
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: