Solved

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

Posted on 1999-01-25
2
621 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
Comment Utility
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
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no 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…
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…
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…

744 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

18 Experts available now in Live!

Get 1:1 Help Now