Results 1 to 2 of 2

Thread: Copying A Folder and Files inside it (Resolved)

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2005
    Posts
    51

    Resolved Copying A Folder and Files inside it (Resolved)

    How can i copy a folder from like a CD, to a place on the computer.

    So far i have code like

    VB Code:
    1. FileCopy App.Path & "\" & "Program Folder", "C:\My Program"

    And to that i get
    Runtime error 75

    path\file access error

    How can i get rid of this?

    thanks
    Last edited by iParadox; Jan 16th, 2005 at 02:02 PM.

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Copying A Folder and Files inside it

    Take a shot at this sample:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Type SHFILEOPSTRUCT
    4.         hwnd As Long
    5.         wFunc As Long
    6.         pFrom As String
    7.         pTo As String
    8.         fFlags As Integer
    9.         fAnyOperationsAborted As Long
    10.         hNameMappings As Long
    11.         lpszProgressTitle As String '  only used if FOF_SIMPLEPROGRESS
    12. End Type
    13.  
    14. Private Const FOF_MULTIDESTFILES = &H1
    15. Private Const FOF_CONFIRMMOUSE = &H2
    16. Private Const FOF_SILENT = &H4
    17. Private Const FOF_RENAMEONCOLLISION = &H8
    18. Private Const FOF_NOCONFIRMATION = &H10
    19. Private Const FOF_WANTMAPPINGHANDLE = &H20
    20. Private Const FOF_CREATEPROGRESSDLG = &H0
    21. Private Const FOF_ALLOWUNDO = &H40
    22. Private Const FOF_FILESONLY = &H80
    23. Private Const FOF_SIMPLEPROGRESS = &H100
    24. Private Const FOF_NOCONFIRMMKDIR = &H200
    25.  
    26. Private Const FO_MOVE = 1
    27. Private Const FO_COPY = 2
    28. Private Const FO_DELETE = 3
    29. Private Const FO_RENAME = 4
    30.  
    31. Private Declare Function SHFileOperation Lib "shell32.dll" (lpFileOp As SHFILEOPSTRUCT) As Long
    32.    
    33. Public Function CopyFolder(ByVal strSource As String, ByVal strDest As String) As Boolean
    34. '==========================================================================================
    35. Dim varFOS As SHFILEOPSTRUCT
    36.     With varFOS
    37.         .fFlags = FOF_NOCONFIRMATION Or FOF_SILENT Or FOF_NOCONFIRMMKDIR
    38.         .wFunc = FO_COPY
    39.         .pFrom = strSource
    40.         .pTo = strDest
    41.     End With
    42.     Call SHFileOperation(varFOS)
    43.     CopyFolder = (varFOS.fAnyOperationsAborted = 0)
    44. End Function
    45.  
    46. Private Sub Command1_Click()
    47. '============================
    48.  
    49.     MkDir "c:\temp_temp1"
    50.     CopyFolder "c:\temp", "c:\temp1"
    51.  
    52. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width