-1

Currently I have 2 exe files. app.exe and updater.exe. When app.exe finds out that there is new version available it runs updater.exe, which downloads and replaces it.

I'm wondering if it's possible to build updater.exe into app.exe. On app start it should check if there is updater.exe in the directory and if it's not than extract it. Any help appreciated.

Andrzej Gis
  • 13,706
  • 14
  • 86
  • 130

3 Answers3

2

You can integrate updater.exe as a resource into app.exe. The following SO post shows how to extract it at run-time:

Note that, if your application is located in the default application directory (C:\Program Files, or, more generally, %ProgramFiles%), you will not have permissions to create a file in the same directory (which is a good thing). Thus, you might need to extract updater.exe into a temporary directory that the current user has write permissions to (such as Path.GetTempPath).

Community
  • 1
  • 1
Heinzi
  • 167,459
  • 57
  • 363
  • 519
0

When I'm understanding you correctly you need to pack you updater.exe into you app.exe as ressource. Extract it, when App.exe starts.

But I can tell you, this idea with replace is bad. You should choose a MSI package to deploy your application.

CodeTherapist
  • 2,776
  • 14
  • 24
0

For traversing and listing directory contents, see http://msdn.microsoft.com/en-us/library/system.io.directory.aspx

For accessing your embedded resources, see http://msdn.microsoft.com/en-us/library/xc4235zt.aspx

For writing binary data to disk, see http://msdn.microsoft.com/en-us/library/system.io.binarywriter.aspx

For running an exe from disk, see http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx

Superbest
  • 25,318
  • 14
  • 62
  • 134