Solved

CopyFolder problem

Posted on 2003-12-04
1
266 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

821 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