[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 645
  • Last Modified:

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

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
mcb123
Asked:
mcb123
1 Solution
 
VBDesignsCommented:
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
 
mcb123Author Commented:
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now