|
-
Dec 8th, 2004, 06:43 AM
#1
Thread Starter
Hyperactive Member
-
Dec 8th, 2004, 01:05 PM
#2
Re: How to copy a directory
Here is a quick sample for you:
Code:
Option Explicit
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 ' only used if FOF_SIMPLEPROGRESS
End Type
Private Const FOF_MULTIDESTFILES = &H1
Private Const FOF_CONFIRMMOUSE = &H2
Private Const FOF_SILENT = &H4
Private Const FOF_RENAMEONCOLLISION = &H8
Private Const FOF_NOCONFIRMATION = &H10
Private Const FOF_WANTMAPPINGHANDLE = &H20
Private Const FOF_CREATEPROGRESSDLG = &H0
Private Const FOF_ALLOWUNDO = &H40
Private Const FOF_FILESONLY = &H80
Private Const FOF_SIMPLEPROGRESS = &H100
Private Const FOF_NOCONFIRMMKDIR = &H200
Private Const FO_MOVE = 1
Private Const FO_COPY = 2
Private Const FO_DELETE = 3
Private Const FO_RENAME = 4
Private Declare Function SHFileOperation Lib "shell32.dll" (lpFileOp As SHFILEOPSTRUCT) As Long
Public Function CopyFolder(ByVal strSource As String, ByVal strDest As String) As Boolean
'==========================================================================================
Dim varFOS As SHFILEOPSTRUCT
With varFOS
.fFlags = FOF_NOCONFIRMATION Or FOF_SILENT Or FOF_NOCONFIRMMKDIR
.wFunc = FO_COPY
.pFrom = strSource
.pTo = strDest
End With
Call SHFileOperation(varFOS)
CopyFolder = (varFOS.fAnyOperationsAborted = 0)
End Function
'usage:
CopyFolder "c:\temp", "c:\temp2"
-
Dec 8th, 2004, 09:20 PM
#3
New Member
Re: How to copy a directory
Or you might try the CopyFolder method of the FileSystemObject object.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|