Solved

Move\Copy Files with\without override

Posted on 2003-12-08
6
563 Views
Last Modified: 2010-05-18
What different methods are available ?

Thank You
-Alex
0
Comment
Question by:AlexF777
  • 5
6 Comments
 
LVL 33

Accepted Solution

by:
hongjun earned 125 total points
Comment Utility
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
 
LVL 33

Expert Comment

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


hongjun
0
 
LVL 33

Expert Comment

by:hongjun
Comment Utility
to check if file exists, do this


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


hongjun
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 33

Expert Comment

by:hongjun
Comment Utility
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
 

Author Comment

by:AlexF777
Comment Utility
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
 
LVL 33

Expert Comment

by:hongjun
Comment Utility
wildcards?
Perhaps you try using Shell api

hongjun
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

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

15 Experts available now in Live!

Get 1:1 Help Now