整个文件夹怎么复制,在线等待,急急...

JonyChen2003 2003-12-19 01:53:01
现在我要把d:\下整个文件夹App(及文件夹中的文件)复制到c:\下,请问我怎么写程序。

谢谢
...全文
47 点赞 收藏 10
写回复
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
fangyds 2003-12-20
Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Private Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Long
hNameMappings As Long
lpszProgressTitle As String '仅用于 FOF_SIMPLEPROGRESS
End Type
Private Const FO_COPY = &H2 '复制


'复制文件
Private Function CopyFile(ByVal sFileFrom As String, ByVal sFileTo As String) As Boolean

Dim fo As SHFILEOPSTRUCT
With fo
.pFrom = sFileFrom
.pTo = sFileTo
.wFunc = FO_COPY
End With
CopyFile = Not (CBool(SHFileOperation(fo)))
End Function

'调用时:
Private Sub Command1_Click()
Debug.Print CopyFile("f:\Music\she", "f:\a")
End Sub
回复
fly 2003-12-19
Dim fs
Set fs = CreateObject("Scripting.FileSystemObject")
fs.CopyFolder "d:\app", "c:\"
回复
逍遥鹰王 2003-12-19
顶!
回复
muchtrouble2003 2003-12-19
用文件系统模型filesystemobject,CopyFolder方法
回复
sunshine781114 2003-12-19
应该可以的啊
回复
sw198002 2003-12-19
把类加上
回复
SoHo_Andy 2003-12-19
试试

Private Sub Command1_Click()
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
fs.CopyFolder "d:\app\", "c:\"
End Sub
回复
JonyChen2003 2003-12-19
yoki:

不行啊,显示

User-defined type not defined
回复
yoki 2003-12-19
Dim fso As New FileSystemObject
fso.CopyFolder "d:\app\", "c:\"
Set fso = Nothing
回复
JonyChen2003 2003-12-19
有人知知到吗
回复
发动态
发帖子
VB基础类
创建于2007-09-28

7451

社区成员

VB 基础类
申请成为版主
社区公告
暂无公告