Solved

CopyFolder problem

Posted on 2003-12-04
1
263 Views
Last Modified: 2011-08-18
Hi All,


1) I'm testing the CopyFolder method of FSO, and found that it does not copy files in the root source directory.  Is that normal?

I.e. if I have 3 files and 3 folders under the source directory, all, except the 3 files in the root source directory, were copied over to the target directory, includes files under the source's sub-directory.

2) How can I set the attributes of all files under a specific directory?

Thanks!
0
Comment
Question by:kwseow
1 Comment
 

Accepted Solution

by:
VKPP earned 125 total points
ID: 9880136
Hi

For yor first question , you can copy all folders and files from one folder to another.

Dim MyObj As New FileSystemObject
Dim MyFolder As Folder
Dim MyFile As File
Dim spath As String, dpath As String

spath = "SourcePath\SFolder"
dpath = "DestinationPath\DFolder"

If MyObj.FolderExists(spath) Then
    MyObj.CopyFolder spath, dpath
End If

This above "CopyFolder" will copy all folders and files.

2) To change attributes of all files in a folder

Set MyFolder = MyObj.GetFolder(dpath)

For Each MyFile In MyFolder.Files
    MyFile.Attributes = ReadOnly ' Whatever you want to set
Next

Hope this will solve ur problem.

VKPP
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now