Solved

CopyFolder problem

Posted on 2003-12-04
1
268 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month9 days, 22 hours left to enroll

623 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