Aug 24, 2001 #1 pcdaveh Technical User Joined Sep 26, 2000 Messages 213 Location US Does anyone know how to copy a folder, not a file from a network drive to your local drive, programatically?
Does anyone know how to copy a folder, not a file from a network drive to your local drive, programatically?
Aug 24, 2001 #2 JohnYingling Programmer Joined Mar 24, 2001 Messages 3,742 Location US 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 http://www.VBCompare.comhttp://www.VBSortGen.com Upvote 0 Downvote
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 http://www.VBCompare.comhttp://www.VBSortGen.com
Aug 24, 2001 #3 Guest_imported New member Joined Jan 1, 1970 Messages 0 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. Upvote 0 Downvote
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.