Results 1 to 5 of 5

Thread: Copy To all folder and Sub Folder

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2007
    Posts
    11

    Copy To all folder and Sub Folder

    Please Help me
    Any one know how can i copy a file to Root folder and all sub folder of Root folder
    only with one click of button

  2. #2
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: Copy To all folder and Sub Folder

    vb Code:
    1. Option Explicit
    2.  
    3. Private Sub command1_Click()
    4.  
    5.     Dim sFolder() As String
    6.     Dim sTmpFolder As String
    7.     Dim sFile As String
    8.     Dim sPath As String
    9.     Dim i As Integer
    10.  
    11.     sPath = "C:\WINDOWS\Desktop\Test"
    12.  
    13.     sTmpFolder = Dir(sPath, vbDirectory)
    14.  
    15.  
    16.     Do While sTmpFolder <> ""
    17.         If sTmpFolder <> "." And sTmpFolder <> ".." Then
    18.             If (GetAttr(sPath & sTmpFolder) And vbDirectory) = vbDirectory Then
    19.                 ReDim Preserve sFolder(0 To i)
    20.                 sFolder(i) = sTmpFolder & "\"
    21.                 i = i + 1
    22.             End If
    23.         End If
    24.         sTmpFolder = Dir
    25.     Loop
    26.    
    27.     Do Until Dir(sPath) = ""
    28.         sFile = Dir(sPath)
    29.         Kill sPath & sFile
    30.     Loop
    31.  
    32.     For i = 0 To UBound(sFolder)
    33.         sTmpFolder = sPath & sFolder(i)
    34.  
    35.         Do Until Dir(sTmpFolder) = ""
    36.             sFile = Dir(sTmpFolder)
    37.             Kill sTmpFolder & sFile
    38.         Loop
    39.  
    40.     Next
    41.  
    42.     Exit Sub
    43.  
    44. End Sub

    This is a function that will delete all the files in all the sub folder and root folder. I know it ain't what your searching for but it might give you an idea of what you are looking at here Sorry i couldn't be of more help i got to be somewhere cya.

  3. #3
    PowerPoster Ellis Dee's Avatar
    Join Date
    Mar 2007
    Location
    New England
    Posts
    3,530

    Re: Copy To all folder and Sub Folder

    Might be overkill for what you're doing, but the folder operations in the class from my signature handle subfolders during copy/move/delete operations.

  4. #4

    Thread Starter
    New Member
    Join Date
    Apr 2007
    Posts
    11

    Re: Copy To all folder and Sub Folder

    ok thanks
    it is not possible

  5. #5
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    Re: Copy To all folder and Sub Folder

    How about the filesystem object
    Code:
    Private Sub Command1_Click()
    Dim fso As FileSystemObject
    
        Set fso = New FileSystemObject
        fso.CopyFolder "C:\images", "c:\temp\images"
        Set fso = Nothing
    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