Solved

How to update executable file in same VS solution

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

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 …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

808 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