Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

CopyFolder problem

Posted on 2003-12-04
1
Medium Priority
?
273 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 375 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

783 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