The Windows operating system will not allow you to overwrite a running application. For this you need another application. One of the processes that I have is that I have download files for the downloadable application, but if they are used, they are given the .update extension.
Then my application at startup searches for any files with this extension in the folder and subfolders. If he finds one, he will launch the patcher application and terminate himself. Patcher waits for the program files to become free, and then moves the .update files over the application files and restarts the application.
It takes an extra second to start when there are updates, but the user does not notice.
In addition: The advantage of a separate updater is its modularity and cleanliness. You can reuse the software for updating, and its code is probably not the foundation of what your application does. Plus, if you don't make it multithreaded, it will affect the interactivity of your application while it is running.
I have seen many programmers take a monolithic approach to deployment (with static assemblies), but modularity still has important advantages if you ask me.
source share