I have a program running in C # that sometimes updates while it runs by replacing exe with a new one. I want the program to regularly check if it has been updated, and if so, restart it. For this, I use the following function.
public static bool DoINeedToRestart(string exe_name) { Version cur_version = new Version(MainProgram.StartVersion); Version file_version = new Version(GetProductVersion(exe_name)); MessageBox.Show("Comparing cur_version " + cur_version.ToString() + " with " + file_version.ToString()); if (file_version > cur_version) { return true; } return false; } public static string GetProductVersion(string path_name) { FileVersionInfo myFI = FileVersionInfo.GetVersionInfo(path_name); return myFI.FileVersion; }
MainProgram.StartVersion is set when the program starts as the current version using GetProductVersion (exe_name)
exe_name is set as the name of the executable that is being updated.
, MainProgram.exe ( , ), GetProductVersion - , , ! . Windows Vista .Net 3.5.
? Windows, , .exe, - Windows. , .NET, , , , .
EDIT: , Windows , , . Vista, , - , , Windows Windows . - , . (MSIEXEC) , . , Windows C:\Program Files\whatever, % USERPROFILE%\AppData\Local\VirtualStore\Program Files\ , . , "" , , , "" . , , .
, - .
restart.txt , ?
restart.txt
Source: https://habr.com/ru/post/1749928/More articles:ASP.NET MVC - how to get value from text field in my view? - htmlBuilding Models in Unit Tests - c #Modbus driver: C vs Java - javaITunes Search Query URL? - urlКак вы получаете доступ к полигонам страны/штата/провинции в google maps api? - androidOverride one css class with another? - jquerySearch HTML table with jQuery - javascriptКак удалить список из - phphttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1749932/can-i-tell-sitecrawlers-to-visit-a-certain-page&usg=ALkJrhgZyKFLZLWu2zDeWeiJscRk6-_eugCancel Long Operation - multithreadingAll Articles