[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 441
  • Last Modified:

How to copy an entire directory in VB6

Hello Experts,

Ok, so I have a quick question I hope.  I am writing a quick application to copy the entire contents of two directories to another directory.  I am programming using VB6, (old school, I know, lol).  Anyway, I am familiar with the standard VB FileCopy command but you can only copy individual files with the command.  Does anyone know of a way I can copy what I need to?  I want to keep the coding as simple as possible.  Thanks in advance!!
0
zraptor
Asked:
zraptor
2 Solutions
 
DMTechGrooupCommented:
' VBScript.
Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
FSO.CopyFile "c:\testfolder\*.*", "c:\copttotestfolder\"

Open in new window


Just use *.* for all files in a directory.
0
 
HooKooDooKuCommented:
The other option is to utilize the DIR$ command to find all the files in a folder and delete them one-by-one with FileCopy...

FileName = DIR$("C:\testfolder\*.*")
while len( FileName )
    FileCopy "C:\testfolder\FileName" "C:\destfolder\FileName"
    FileName = DIR$    'This will get the next file the 1st DIR command found
wend
0
 
zraptorAuthor Commented:
Thank you!!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now