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 IamaSherpa 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 1

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?
 
Use the Name statement

Renames a disk file, directory, or folder.

Syntax

Name oldpathname As newpathname

The Name statement syntax has these parts:

Part Description
oldpathname Required. String expression that specifies the existing file name and location — may include directory or folder, and drive.
newpathname Required. String expression that specifies the new file name and location — may include directory or folder, and drive. The file name specified by newpathname can't already exist.

Remarks

The Name statement renames a file and moves it to a different directory or folder, if necessary. Name can move a file across drives, but it can only rename an existing directory or folder when both newpathname and oldpathname are located on the same drive. Name cannot create a new file, directory, or folder.

Using Name on an open file produces an error. You must close an open file before renaming it. Name arguments cannot include multiple-character (*) and single-character (?) wildcards.
 
Public Sub backup()
On Error GoTo jason2

Dim date1 As Variant
Dim fil
Dim fso
Dim fill2
Dim fso2
date1 = Format(Date, "MM-DD-YYYY")
Set fso = CreateObject("scripting.filesystemobject")
Set fso2 = CreateObject("scripting.filesystemobject")
Set fill = fso.getfile("H:\IV\IV2000.mdb")
Set fill2 = fso2.createfolder("c:\itbackup\itdb" & date1)
fill.Copy ("c:\itbackup\itdb" & date1 & "\")
jason2:
Exit Sub
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top