Solved

Move\Copy Files with\without override

Posted on 2003-12-08
6
565 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
ID: 9898483
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
ID: 9898489
' 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
ID: 9898493
to check if file exists, do this


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


hongjun
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 33

Expert Comment

by:hongjun
ID: 9904535
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
ID: 9909466
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
ID: 9909474
wildcards?
Perhaps you try using Shell api

hongjun
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
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…
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…

803 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