Solved

FSO - CopyFile method w/Wild char - prob read-only attrib

Posted on 1999-01-25
2
626 Views
Last Modified: 2008-02-01
I am using FSO's CopyFile method to copy multiple files (e.g.: A:\*.*) with the 'Force' = "True" (destination not important).  Users are allowed to copy files more than once.

Problem is that when trying to recopy files with "Read-Only" attrib, system comes up with err#70.  I can fix that with getattr and setattr IF I KNOW WHAT THE FILENAME IS.  Since I am using *.* as source with FSO, how do I get the filename it had a problem with.

If this can't be done using wild char (*.*), how else can I get the file list so I can copy one at a time?
0
Comment
Question by:mcb123
2 Comments
 
LVL 2

Accepted Solution

by:
VBDesigns earned 100 total points
ID: 1470560
Build the filelist something like this (note using a Dir() retrieves the next file name matching the wildcard):

Dim sFile as String
Dim iLoop as Integer
ReDim sFiles(0) as String

sFile=Dir("c:\*.*")
Do
    sFiles(Ubound(sFiles)) = sFile
    Redim Preserve sFiles(Ubound(sFiles)+1) as String
    sFile = Dir()
Loop while sFile<>""

' Now we have the list of all files in that dir
for iLoop = 0 to (Ubound(sFiles) - 1)
     ' Do your GetAttr and SetAttr here!
Next
0
 

Author Comment

by:mcb123
ID: 1470561
Thanks for your help.  I appreciate the fast response.

To handle the subfolders, I plan to use the recursive method - do you know if that would be the fastest method to do it?

My whole plan is to copy the entire content of a drive to another location and update a table with what was copied (file names with path info).

Thanks again for your help.
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

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…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
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…

730 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