Solved

How to update executable file in same VS solution

Posted on 2006-11-30
6
163 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

758 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now