Solved

Copying currently open file

Posted on 1998-09-23
10
153 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

695 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