Solved

How to update executable file in same VS solution

Posted on 2006-11-30
6
168 Views
Last Modified: 2010-04-23
In a VS .Net 2003 solution I have a project called «App1».

From this project «App1» I can download an updated version of the exe called «App1_UPDATED.exe», put it in the same folder as «App1» and close the application.

Question:
Next time I start this VS .Net 2003 solution, I would like to check if there is a file called «App1_UPDATED.exe», and if so, delete «App1.exe», rename «App1_UPDATED.exe» to «App1.exe» and launch the newly updated «App1.exe».

What would be the best way ?

scml
0
Comment
Question by:scml
  • 3
6 Comments
 
LVL 16

Accepted Solution

by:
Hillwaaa earned 125 total points
ID: 18049349
Hi scml,

If I understand you correctly, you could do the following in your application startup code:

        Dim pathToAppUpdated As String = "c:\somepath\app_updated.exe"
        Dim pathToApp As String = "c:\somepath\app.exe"
        If IO.File.Exists(pathToAppUpdated) Then
            IO.File.Delete(pathToApp)
            IO.File.Copy(pathToAppUpdated, pathToApp)
            IO.File.Delete(pathToAppUpdated)
        End If

Cheers,
Hillwaaa
0
 
LVL 15

Expert Comment

by:Solar_Flare
ID: 18049374
Why do you want to do this? each time you build the app1 project it will overwrite the app1.exe file.
0
 
LVL 15

Expert Comment

by:Solar_Flare
ID: 18049381
sorry i misunderstood. disregard that last comment.
0
 
LVL 15

Assisted Solution

by:Solar_Flare
Solar_Flare earned 125 total points
ID: 18049425
to do what you want you will need to use a separate application, as your application will not be able to remove/update itself. The process app1.exe cannot be running when you try to do it otherwise you will get an error.


you could create a startup application called something like "start.exe" which checks to see if an updated version exists then starts the application

dim path as string = application.startuppath
if system.io.file.exists(path & "\app1_updated.exe") then
     IO.File.Move(path & "\app1_updated.exe", path & "\app1.exe")
end if

'now run the application
system.diagnostics.process.start(path & "\app1.exe")

0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 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