http://www.webuc.net/ddf3/archive/2005/08/25/6142.aspx
不用FSO的复制文件夹得方法?用API函数 SHFileOperation以下是使用SHFileOperation删除复制移动文件的例子,可以复制文件夹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 TypePrivate Declare Function SHFileOperation Lib _"shell32.dll" Alias "SHFileOperationA" (lpFileOp _As SHFILEOPSTRUCT) As Long'wFunc 常数'FO_COPY 把 pFrom 文件拷贝到 pTo。Const FO_COPY = &H2'FO_DELETE 删除 pFrom 中的文件(pTo 忽略)。Const FO_DELETE = &H3'FO_MOVE 把 pFrom 文件移动到 pTo。Const FO_MOVE = &H1'fFlag 常数'FOF_ALLOWUNDO 允许 Undo 。Const FOF_ALLOWUNDO = &H40'FOF_NOCONFIRMATION 不显示系统确认对话框。Const FOF_NOCONFIRMATION = &H10'FOF_NOCONFIRMMKDIR 不提示是否新建目录。Const FOF_NOCONFIRMMKDIR = &H200'FOF_SILENT 不显示进度对话框Const FOF_SILENT = &H4'例子:Dim SHFileOp As SHFILEOPSTRUCT' 删除SHFileOp.wFunc = FO_DELETE SHFileOp.pFrom = "c:/config.old" + Chr(0)SHFileOp.fFlags = FOF_ALLOWUNDO + FOF_NOCONFIRMATIONCall SHFileOperation(SHFileOp)' 删除多个文件SHFileOp.wFunc = FO_DELETESHFileOp.pFrom = "c:/config.old" +Chr(0) + "c:/autoexec.old"+Chr(0)SHFileOp.fFlags = FOF_ALLOWUNDOCall SHFileOperation(SHFileOp)' 拷贝SHFileOp.wFunc = FO_COPY SHFileOp.pFrom = "c:/t"SHFileOp.pTo = "d:/"SHFileOp.fFlags = FOF_ALLOWUNDO + FOF_NOCONFIRMMKDIRCall SHFileOperation(SHFileOp)' 移动SHFileOp.wFunc = FO_MOVE SHFileOp.pFrom = "c:/config.old" + Chr(0)SHFileOp.pTo = "d:/t"SHFileOp.fFlags = FOF_ALLOWUNDO + FOF_NOCONFIRMATIONCall SHFileOperation(SHFileOp)或者shell "cmd.exe /c xcopy "+chr(34)+"C:/新建文件夹 c:/aa /q /e" +chr(34)
原文链接:https://www.f2er.com/vb/262325.html