Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy Folder From H:\somepath to, C:\somepath

Status
Not open for further replies.

pcdaveh

Technical User
Sep 26, 2000
213
US
Does anyone know how to copy a folder, not a file from a network drive to your local drive, programatically?
 
You can use the FileSystemObject to COPY/MOVE a folder or go with Dir$(*.*) and FileCopy each file individually.
Code:
strSourcePath = "H:\folder\"
strDestPath = "c:\folder\"
strDir = Dir$(strSourcePath & "*.*")
Do While(Len(strDir) > 0)
    FileCopy strPathSource & strDir, strDestPath & strDir
    strDir = Dir()
Loop
 
Hi...this worked for me

Dim objFS As FileSystemObject
Dim objFolder As Folder

Set objFS = New FileSystemObject
Set objFolder = objFS.GetFolder("X:\scripts")
objFolder.Copy "C:\pb"

Set objFs = nothing
Set objFolder = nothing

it copied all contents in the folder including subdirectories. hope it helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top