I looked at a simple mechanism for self-updating executable files. (I cannot use Click-Once due to the nature of the application - trust me on this)
I noticed that the in-flight assembly may move to another location on the disk, apparently because the executing assembly is actually a copy in memory) and that the original location of the file may be overwritten. This is confirmed by the following fragment of the evidence concept ...
string assemblyStart = System.Reflection.Assembly.GetExecutingAssembly().Location; Console.WriteLine(assemblyStart); if(File.Exists(@"C:\ANewExe.exe")) { File.Delete(@"C:\ANewExe.exe"); } File.Move(assemblyStart,@"C:\ANewExe.exe"); string assemblyMoved = System.Reflection.Assembly.GetExecutingAssembly().Location; Console.WriteLine(assemblyMoved);
In my XP development system, this leads to the build file being moved to c:\ANewExe.exe , and the original location of the file is filled with the text "some text".
I think my question is whether this is a safe and / or reliable method for use in different versions of Windows with XP), or are there other ways to achieve this functionality? Will this be detected as a possible behavior of viruses using AV systems, to which I do not have access for testing?
TIA
source share