Removing extra files after uninstalling a clickonce application

烂漫一生 提交于 2020-01-06 08:41:34

问题


I have a project that uses clickonce to generate the setup.exe. During the run time my program create some extra files like "Log" and "Attachments" inside the User Folder. However, those folders are not removed when I perform an uninstall of the clickonce application from the ARP. These remaining files are interfering the next install.

I know that click once does not support for adding custom action to install or uninstall. I am wondering if is there is a way that I can remove those extra file programmingly after performing uninstall?

One way I have tried was to create a cleanup script and added it as a bootstrapper package to pre-requisite of the click once project. That worked in a way that every time before a new product was installed, the previous dirty data had been removed. However, this messed up the upgrade case.

Any ideas on how to remove the extra files that left by clickonce uninstallation?

Thank you

JS


回答1:


There is no way to do anything when uninstalling a ClickOnce application other than uninstall the ClickOnce application.

Have you considered putting the files in the ApplicationDeployment.CurrentDeployment.DataDirectory ? Then they will be removed when the application is unisntalled.

If the files are part of the project, you can set the type to Data in the Application Files dialog, and it will automatically place them in the data directory when deploying.




回答2:


This solution works on multiple re-installations (clean), however it doesn't remove the data on last uninstall or until the next installation takes place.

Stil there is no custom action place on uninstall to remove the files beyond clickonce scope.

Leave a file in to ApplicationDeployment.CurrentDeployment.DataDirectory.

On startup, see if the file exists on conditions network deployed, firstrun (which resets on upgarde too).. success case, it is a first installation or upgrade. Failure case, the application is been uninstalled and installing again .. now you have a chance to clean up the application data.

If the data is sensitive, you may want to use other solution to remove files on uninstall ( as of now I don't see that Microsoft is given us an option)



来源:https://stackoverflow.com/questions/7829151/removing-extra-files-after-uninstalling-a-clickonce-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!