Solved

Copying currently open file

Posted on 1998-09-23
10
150 Views
Last Modified: 2010-04-30
I need to copy my application(which is running, and where this code will be) to another directory.  I know with FileCopy it gives an error if you try to copy an open file(I think) How can I do this?
0
Comment
Question by:bomax
  • 5
  • 3
  • 2
10 Comments
 
LVL 2

Expert Comment

by:AllenC_Jr
ID: 1436320
Use File Copy...
0
 

Author Comment

by:bomax
ID: 1436321
You are very stupid Allan C!!!!!   I said I CAN NOT use filecopy because it gives an ERROR!  Does anyone else know how to?
0
 
LVL 2

Expert Comment

by:AllenC_Jr
ID: 1436322
I Do Not Really Appreciate Being Called Stupid...

I HAVE Used FileCopy, If It doesn't Work For you than to **** Bad...
0
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
LVL 1

Expert Comment

by:toys032498
ID: 1436323
I ELECT THAT WE BAN BOMAX FROM EXPERTS EXCHANGE.  
This sight is for Professionals, not rude people.  We do this for free and we all dont appreciate your unprofessional manner.

PLEASE LEAVE THIS SITE AND DONT EVER RETURN UNTILL YOU APPOLIGIZE TO US ALL!

Anthony
0
 
LVL 2

Expert Comment

by:AllenC_Jr
ID: 1436324
BOMAX If You Are Running the Program In the VB IDE Then IT will error, because it you try to copy the exe from the App.path & App.Exename It Tries to Copy it this way
WhatEverVbIsRunningUnder & App.ExeName

I Have Compiled an Executable that Copies it's self to my C:\ Drive and it doesn't Error, So Don't Do the FileCopy From The IDE, Compile the Program to do this...
0
 

Author Comment

by:bomax
ID: 1436325
Okay, I apologize.  I was very upset when I wrote the comment.  If you could PLEASE provide some code example, AllenC, I would appreciate it very much.  Again, I AM SORRY ALLAN!!!!!!!!!!!!!  I will also increase points....
0
 
LVL 2

Accepted Solution

by:
AllenC_Jr earned 70 total points
ID: 1436326
Sample Code
For Compiled Executables Only

Public Sub CopyMe(NewFilePath)
If Right(app.path,1) = "\" Then
FileCopy App.Path & "AppExeNameHere.exe", NewFilePath
Else
FileCopy App.Path & "\AppExeNameHere.exe", NewFilePath
End If
End Sub

Private Sub Form_Load()
CopyMe "C:\Windows\New.exe"
End Sub
0
 
LVL 1

Expert Comment

by:toys032498
ID: 1436327
Thank you for being a Gentleman. I know we all have !@#$ days.
Anthony
0
 

Author Comment

by:bomax
ID: 1436328
Well......my exe name will be changing a lot, so is there anyway to get the exe name at run-time?  other than that it looks very nice, I will grade it after you tell me how(if possible) to get the exe name at run-time. thanks!
0
 
LVL 2

Expert Comment

by:AllenC_Jr
ID: 1436329
Possibly App.EXEName?
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

820 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