Go Premium for a chance to win a PS4. Enter to Win

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

Move\Copy Files with\without override

What different methods are available ?

Thank You
-Alex
0
AlexF777
Asked:
AlexF777
  • 5
1 Solution
 
hongjunCommented:
try this
include "Microsoft Scripting Runtime" from project-references


Dim fso As FileSystemObject

Set fso = New FileSystemObject
fso.CopyFile "c:\sourcefile.txt", "c:\destination.txt", False
fso.MoveFile "c:\sourcefile.txt", "c:\destination.txt"

Set fso = Nothing


hongjun
0
 
hongjunCommented:
' false means do not override
' true means override
fso.CopyFile "c:\sourcefile.txt", "c:\destination.txt", False


hongjun
0
 
hongjunCommented:
to check if file exists, do this


If fso.FileExists("c:\myfile.txt") Then
    MsgBox "File Exist"
End If


hongjun
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
hongjunCommented:
Thanks for selecting my comment as the answer. But why the grade of "B"? It could have been an A grade since my comment solved your problem directly. Note that a grade A given does not differ from a grade B or C to a questionner. It will not affect your question points value but rather it only affect your grading record. Your grading record will be better if you shows consistent A grading awarding habit.

Please see Tip #11 - Grade quickly and fairly
http://cd-eepages.fateback.com/asking.html

Please explain the reason for the B grade.

hongjun
0
 
AlexF777Author Commented:
Ok, what I am trying to accomplish is to override destination files if they already exist ( would be nice to be able
to use wild-cards too ).

fso.CopyFile will do it but only if destination is not read-only, fso.MoveFile -will not do it at all.

may be I am wrong ?

-Al

0
 
hongjunCommented:
wildcards?
Perhaps you try using Shell api

hongjun
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.

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