?
Solved

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

Posted on 1999-01-25
2
Medium Priority
?
635 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
[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
2 Comments
 
LVL 2

Accepted Solution

by:
VBDesigns earned 300 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
Suggested Courses

765 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