Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Copying currently open file

Posted on 1998-09-23
10
Medium Priority
?
157 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
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.

 
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 280 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

Technology Partners: 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

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…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

636 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