over write running .exe

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using FTP built in to my application to update the application and data
from a server...

What is the normal method folks use to over write the application while the
program is active? What I am running into is that the FTP code will not over
write the .exe while the application is running.

Do any other types of application extension files have the same issue with
not wanting to be updated while the application is running: .dll, etc.??
 
BobAchgill said:
I am using FTP built in to my application to update the application and data
from a server...

What is the normal method folks use to over write the application while the
program is active? What I am running into is that the FTP code will not over
write the .exe while the application is running.

Do any other types of application extension files have the same issue with
not wanting to be updated while the application is running: .dll, etc.??

Impossible, you can't overwrite files that are in use (be it
executables, dll or whatever). Maybe you could write a sort of
monitoring program that will detect a new upload (to a specified
directory), shut down the program, copy/move the new program and start
the new version.
 
Bob,
Actually this is very much possible & actually quite easy in .NET. As Rinze
suggests normally one cannot "overwrite files that are in use", however .NET
has the ability to create a shadow copy of executables, such that you can
replace the original executable with the new one. To create a shadow copy of
an executable you set the shadow copy option when creating a new AppDomain,
then load your executable in this second app domain. This implies that your
app has a loader "stub" that creates the app domain & executes your actual
program. Using a FileSystemWatcher you could have the AppDomain
automatically restarted when a new version of the app is saved (However I
would simply inform my user to exit & restart the app).

http://msdn.microsoft.com/library/d.../frlrfSystemIOFileSystemWatcherClassTopic.asp



In .NET 2.0 (VS 2005) using ClickOnce is one of the easiest ways to
implement this app loader/updater.

Alternatively (.NET 1.x VS 2003) you can look at the Updater Application
Block:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/updaterv2.asp

--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net


|I am using FTP built in to my application to update the application and
data
| from a server...
|
| What is the normal method folks use to over write the application while
the
| program is active? What I am running into is that the FTP code will not
over
| write the .exe while the application is running.
|
| Do any other types of application extension files have the same issue with
| not wanting to be updated while the application is running: .dll, etc.??
 
Jay said:
Bob,
Actually this is very much possible & actually quite easy in .NET. As Rinze
suggests normally one cannot "overwrite files that are in use", however .NET
has the ability to create a shadow copy of executables, such that you can
replace the original executable with the new one. To create a shadow copy of
an executable you set the shadow copy option when creating a new AppDomain,
then load your executable in this second app domain. This implies that your
app has a loader "stub" that creates the app domain & executes your actual
program. Using a FileSystemWatcher you could have the AppDomain
automatically restarted when a new version of the app is saved (However I
would simply inform my user to exit & restart the app).

http://msdn.microsoft.com/library/d.../frlrfSystemIOFileSystemWatcherClassTopic.asp



In .NET 2.0 (VS 2005) using ClickOnce is one of the easiest ways to
implement this app loader/updater.

Alternatively (.NET 1.x VS 2003) you can look at the Updater Application
Block:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/updaterv2.asp

Wow.. you learn something new every day :) I was quite unaware of this.
 
Back
Top