c# - Delete application files after it runs -
i'm busy creating custom uninstall application.
i know how delete application programmaticly after has run. i'm using standard winform app coded in c#
we have application uses clickonce deployment. wish create uninstall function that. have uninstall working fine, need delete uninstall application well. should single exe file needs deleted, after it's done thing.
i not wish have remaining file left on user's machine
i think question asked here. have use movefileex api, which, when given movefile_delay_until_reboot flag, delete specified file on next system startup.
here have sample:
internal enum movefileflags { movefile_replace_existing = 1, movefile_copy_allowed = 2, movefile_delay_until_reboot = 4, movefile_write_through = 8 } [system.runtime.interopservices.dllimportattribute("kernel32.dll",entrypoint="movefileex")] internal static extern bool movefileex(string lpexistingfilename, string lpnewfilename, movefileflags dwflags); movefileex(filetodelete, null, movefileflags.movefile_delay_until_reboot);
Comments
Post a Comment