简体   繁体   English

.NET安装项目,在卸载时删除安装文件夹

[英].NET Setup Project Remove Installtion Folder On Uninstall

I have a .NET setup project that installs and uninstalls my application fine but on uninstall it leaves the installation directory behind. 我有一个.NET安装项目,可以很好地安装和卸载我的应用程序,但是在卸载时,它会留下安装目录。

How can I delete this folder during/after the uninstall? 在卸载过程中/卸载后如何删除此文件夹?

UPDATE: My application creates a cahce file in this directory when it runs which looks like the reason the folder is not removed during the uninstall. 更新:我的应用程序在运行时会在此目录中创建一个cahce文件,这似乎是卸载期间未删除文件夹的原因。

Is there a way to remove this file so that the folder gets removed? 有没有办法删除此文件,以便删除该文件夹?

Normally the folder created during installation will be removed on uninstall. 通常,在安装过程中创建的文件夹将在卸载时删除。

This does not happen however, if that folder is not empty or another process has an open handle to that folder or a subfolder within. 但是,如果该文件夹不为空,或者另一个进程对该文件夹或其中的子文件夹具有打开的句柄,则不会发生这种情况。 Therefore you should make sure that the folder is not opened somewhere in Explorer or a console window, you application is not running and you didn't place any additional files to that folder. 因此,您应该确保未在资源管理器或控制台窗口中的某个位置打开该文件夹,您的应用程序未在运行,并且没有在该文件夹中放置任何其他文件。

You can check with Process Explorer for open handles using the Find -> Find Handle or Dll command and entering the name of your installation folder. 您可以使用“ 查找”->“查找句柄”或“ Dll”命令并输入安装文件夹的名称,使用Process Explorer检查打开的句柄。

You can get extended information and possible error messages by creating a log of your uninstallation: 您可以通过创建卸载日志来获取扩展信息和可能的错误消息:

msiexec /x myProgram.msi /l*vx log.txt

yes you can remove these files/Folder by writing Custom Actions and adding entries in Remove File table. 是的,您可以通过编写“自定义操作”并在“删除文件”表中添加条目来删除这些文件/文件夹。 RemoveFile RemoveFile

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM