Click here to Skip to main content
15,889,867 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Recent supplying code(Shell("xcopy /S source destination,vbMaximizedFocus) is not copy my project..
Again i send same little change coding.

Please send me proper vb6 code..

I want to copy of Folder, Sub-Folder & their contain of files from one location(C:\Program Files\Common Files\Common\MNCP) to another location(C:\Program Files\MNCPSetup) by VB6 language.

Note : Copying(MNCP) Folder have contain sub-folder & many files.

How can i solve this problem????
Please Send me proper vb6 coding as early as possible.....
I wait for answer....
Posted
Updated 29-Oct-11 0:57am
v2

The simplest way:
Shell("xcopy /S source destination", vbMaximizedFocus)

Best regards
Espen Harlinn
 
Share this answer
 
Here is my code to copy file in sub of subforder into new folder

VB
Option Explicit
Public Arr() As String
Public Counter As Long

Sub LoopThroughFilePaths()
    Dim j As Long
    Dim MyFile As String
    Dim strSource As String
    Dim strDest As String
    strSource = "S:\ACC\ACC Common share\New\Original Data from System\CIC Original"
    strDest = "S:\ACC\ACC Common share\New\ACC-Report in Vietnam\CIC\Monthly_Credit Infor\CIC Report"
    ReDim Arr(0)
    Counter = 0
    Arr(0) = strSource
    Arr = GetSubFolders(strSource)
    'Application.ScreenUpdating = False
    'Application.DisplayAlerts = False

    For j = LBound(Arr) To UBound(Arr)
        Call XcopyFiles(Arr(j) & "\CREDIT_INFO_*.XLS", strDest)
    Next j
End Sub

Function GetSubFolders(RootPath As String)
    Dim fso As Object
    Dim fld As Object
    Dim sf As Object
    Dim myArr
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set fld = fso.GetFolder(RootPath)
    For Each sf In fld.subfolders
        Counter = Counter + 1
        ReDim Preserve Arr(Counter)
        Arr(Counter) = sf.Path
        myArr = GetSubFolders(sf.Path)
    Next
    GetSubFolders = Arr
    Set sf = Nothing: Set fld = Nothing: Set fso = Nothing
End Function

Sub XcopyFiles(strSource, strDestination)
Dim wsh As Object
    Set wsh = CreateObject("wscript.shell")
    wsh.Run "xcopy.exe """ & strSource & """ """ & strDestination & """ /y /r", 1, True
    'Application.ScreenUpdating = False
    'Application.DisplayAlerts = False
    Set wsh = Nothing
End Sub
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900