Hi jokler.007,
I think Johnny J.'s answer is good and helps you with the involved steps.
It depends on your needs what you have to do to get a good user experience. Consider not rolling your own solution but use prepared deployment solutions like ClickOnce which have updater included.
If you want to create your own "System" it may help to hear what I did:
Updater.exe is started out of my Target.exe (a Windows application)
Updater.exe terminates Target.exe (or waits for Termination if Target.exe closed itself)
Updater.exe searches for possible updates on (configurabale) update sources (local, Network, Internet)
If update sources are found Updater.exe does a Version check - if a newer Version is available.
If newer Version was found download/copy as new Target.exe
Updater.exe starts Target.exe again and closes itself.
Of course a lot of other "routs" could be taken - just an example.
My solution had some key points - maybe the code helps/inspires you:
Wait for process to Exit
static bool WaitForProcessExit(string strProcessName, int iWaitTime)
{
Process[] aProcs = Process.GetProcessesByName(strProcessName);
if (aProcs != null && aProcs.Length > 0)
{
return aProcs[0].WaitForExit(iWaitTime);
}
return true;
}
compare assembly versions of files to update without loading them:
static Version GetVersionFromAssemblyFullName(string strAssemblyPath)
{
string strVersion = AssemblyName.GetAssemblyName(strAssemblyPath).FullName.Split(",".ToCharArray())[1].Split("=".ToCharArray())[1];
return new Version(strVersion);
}
Version versionNew = GetVersionFromAssemblyFullName(strNewAssemblyPath);
Version versionOld = GetVersionFromAssemblyFullName(strCurrentAssemblyPath);
if (versionNew > versionOld)
...
greetings Johannes